-
Notifications
You must be signed in to change notification settings - Fork 19
/
message.go
70 lines (64 loc) · 3.53 KB
/
message.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
// Copyright Infratographer, Inc. and/or licensed to Infratographer, Inc. under one
// or more contributor license agreements. Licensed under the Elastic License 2.0;
// you may not use this file except in compliance with the Elastic License 2.0.
// Package pubsubx provides common utilities and formats for working with pubsub systems
package pubsubx
import (
"time"
"go.infratographer.com/x/gidx"
)
// FieldChange represents a single field that was changed in a changeset and is used to map fields to the old and new values
type FieldChange struct {
// Field is the name of the field that changed
Field string `json:"field"`
// PreviousValue is the value the field had before the change
PreviousValue string `json:"previousValue"`
// CurrentValue is the new value of the field after the change
CurrentValue string `json:"currentValue"`
}
// ChangeMessage contains the data structure expected to be received when picking
// an event from a changes message queue
type ChangeMessage struct {
// SubjectID is the PrefixedID representing the node of the topic of this message
SubjectID gidx.PrefixedID `json:"subjectID"`
// EventType describes the type of event that has triggered this message
EventType string `json:"eventType"`
// AdditionalSubjectIDs is a group of PrefixedIDs representing additional nodes associated with this message
AdditionalSubjectIDs []gidx.PrefixedID `json:"additionalSubjects"`
// ActorID is the PrefixedID representing the identity of the actor that caused this message to be triggered
ActorID gidx.PrefixedID `json:"actorID"`
// Source is a string representing the identity of the source system that created the message
Source string `json:"source"`
// Timestamp is the time representing when the message was created
Timestamp time.Time `json:"timestamp"`
// TraceID is the ID of the trace for this event
TraceID string `json:"traceID"`
// SpanID is the ID of the span that additional traces should based off of
SpanID string `json:"spanID"`
// SubjectFields is a map of the fields on the subject
SubjectFields map[string]string `json:"subjectFields"`
// Changeset is an optional map of the fields that changed triggering this message, this should be provided if the source can provide a changeset
FieldChanges []FieldChange `json:"fieldChanges"`
// AdditionalData is a field to store any addition information that may be important to include with your message
AdditionalData map[string]interface{} `json:"additionalData"`
}
// EventMessage contains the data structure expected to be received when picking
// an event from an events message queue
type EventMessage struct {
// SubjectID is the PrefixedID representing the node of the topic of this message
SubjectID gidx.PrefixedID `json:"subjectID"`
// EventType describes the type of event that has triggered this message
EventType string `json:"eventType"`
// AdditionalSubjectIDs is a group of PrefixedIDs representing additional nodes associated with this message
AdditionalSubjectIDs []gidx.PrefixedID `json:"additionalSubjects"`
// Source is a string representing the identity of the source system that created the message
Source string `json:"source"`
// Timestamp is the time representing when the message was created
Timestamp time.Time `json:"timestamp"`
// TraceID is the ID of the trace for this event
TraceID string `json:"traceID"`
// SpanID is the ID of the span that additional traces should based off of
SpanID string `json:"spanID"`
// Data is a field to store any information that may be important to include about the event
Data map[string]interface{} `json:"data"`
}