diff options
author | Matthias Simon <matthias.simon@nokia.com> | 2021-04-23 09:17:37 +0200 |
---|---|---|
committer | Matthias Simon <matthias.simon@nokia.com> | 2021-04-23 09:17:37 +0200 |
commit | 028d5c03f961ead7072066c3eaf9f7df65ffd791 (patch) | |
tree | 248f9d2158ae625f24dfdd16eabcc34485d0c512 /bridge/gitlab/event.go | |
parent | aa4e225a80b37ce26f5f8c69041ee735f512b113 (diff) | |
download | git-bug-028d5c03f961ead7072066c3eaf9f7df65ffd791.tar.gz |
Add some documentation comments
Diffstat (limited to 'bridge/gitlab/event.go')
-rw-r--r-- | bridge/gitlab/event.go | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/bridge/gitlab/event.go b/bridge/gitlab/event.go index a2e30b0b..875b3cf4 100644 --- a/bridge/gitlab/event.go +++ b/bridge/gitlab/event.go @@ -10,6 +10,14 @@ import ( "github.com/xanzy/go-gitlab" ) +// Event represents a unified GitLab event (note, label or state event). +type Event interface { + ID() string + UserID() int + Kind() EventKind + CreatedAt() time.Time +} + type EventKind int const ( @@ -34,23 +42,6 @@ const ( EventMentionedInMergeRequest ) -type Event interface { - ID() string - UserID() int - Kind() EventKind - CreatedAt() time.Time -} - -type ErrorEvent struct { - Err error - Time time.Time -} - -func (e ErrorEvent) ID() string { return "" } -func (e ErrorEvent) UserID() int { return -1 } -func (e ErrorEvent) CreatedAt() time.Time { return e.Time } -func (e ErrorEvent) Kind() EventKind { return EventError } - type NoteEvent struct{ gitlab.Note } func (n NoteEvent) ID() string { return fmt.Sprintf("%d", n.Note.ID) } @@ -149,6 +140,17 @@ func (s StateEvent) Kind() EventKind { } } +type ErrorEvent struct { + Err error + Time time.Time +} + +func (e ErrorEvent) ID() string { return "" } +func (e ErrorEvent) UserID() int { return -1 } +func (e ErrorEvent) CreatedAt() time.Time { return e.Time } +func (e ErrorEvent) Kind() EventKind { return EventError } + +// SortedEvents consumes an Event-channel and returns an event slice, sorted by creation date, using CreatedAt-method. func SortedEvents(c <-chan Event) []Event { var events []Event for e := range c { |