aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab/event.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/gitlab/event.go')
-rw-r--r--bridge/gitlab/event.go36
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 {