forked from meshery/meshkit
/
build.go
71 lines (57 loc) · 1.35 KB
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package events
import (
"time"
"github.com/gofrs/uuid"
)
type EventBuilder struct {
event Event
}
func NewEvent() *EventBuilder {
operationId, _ := uuid.NewV4()
return &EventBuilder{
event: Event{
CreatedAt: time.Now(),
OperationID: operationId,
Status: Unread,
},
}
}
func (e *EventBuilder) ActedUpon(resource uuid.UUID) *EventBuilder {
e.event.ActedUpon = resource
return e
}
func (e *EventBuilder) WithDescription(description string) *EventBuilder {
e.event.Description = description
return e
}
func (e *EventBuilder) WithCategory(eventCategory string) *EventBuilder {
e.event.Category = eventCategory
return e
}
func (e *EventBuilder) WithAction(eventAction string) *EventBuilder {
e.event.Action = eventAction
return e
}
func (e *EventBuilder) WithMetadata(metadata map[string]interface{}) *EventBuilder {
e.event.Metadata = metadata
return e
}
func (e *EventBuilder) WithSeverity(severity EventSeverity) *EventBuilder {
e.event.Severity = severity
return e
}
func (e *EventBuilder) WithStatus(status EventStatus) *EventBuilder {
e.event.Status = status
return e
}
func (e *EventBuilder) FromUser(id uuid.UUID) *EventBuilder {
e.event.UserID = &id
return e
}
func (e *EventBuilder) FromSystem(id uuid.UUID) *EventBuilder {
e.event.SystemID = id
return e
}
func (e *EventBuilder) Build() *Event {
return &e.event
}