Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeEvent ¶
func DecodeEvent(data interface{}) (interface{}, error)
DecodeEvent tries to decode a received message to either a PositionEvent, LifeycleEvent or SubscriptionEvent
Types ¶
type EntityType ¶
type EntityType string
EntityType defines a type of entity ot be used in an event
const ( // TeamEntity is a team entity TeamEntity EntityType = "team" // TrackerEntity is a tracker entity TrackerEntity EntityType = "tracker" // CollectionEntity is a collection entity CollectionEntity EntityType = "collection" // SubscriptionEntity is a subscription entity SubscriptionEntity EntityType = "subscription" // ShapeCollectionEntity is a shape collection entity ShapeCollectionEntity EntityType = "shapecollection" )
type LifeCycleEvent ¶
type LifeCycleEvent struct { Type EventType `json:"type"` Data LifecycleEventDetails `json:"data"` }
LifeCycleEvent wraps an event with a type identifier to help distinguish the event from other events
func NewLifecycleEvent ¶
func NewLifecycleEvent(eventType LifeCycleEventType, entityType EntityType, id int64) *LifeCycleEvent
NewLifecycleEvent returns a new wrapped LifecycleEvent
func (*LifeCycleEvent) EventType ¶
func (lifecycleEvent *LifeCycleEvent) EventType() EventType
EventType returns the Lifecycle event type
type LifeCycleEventType ¶
type LifeCycleEventType string
LifeCycleEventType defines a lifecycle type
const ( // CreatedEvent is when an entity is created CreatedEvent LifeCycleEventType = "created" // UpdatedEvent is when an entity is updated UpdatedEvent LifeCycleEventType = "updated" // DeletedEvent is when an entity is deleted DeletedEvent LifeCycleEventType = "deleted" )
type LifecycleEventDetails ¶
type LifecycleEventDetails struct { Type LifeCycleEventType `json:"type"` EntityType EntityType `json:"entityType"` EntityID int64 `json:"entityId"` }
LifecycleEventDetails is a struct to be used for events triggered by a lifecycle change
type PositionEvent ¶
type PositionEvent struct { Type EventType `json:"type"` Data PositionEventDetails `json:"data"` }
PositionEvent wraps an event with a type identifier to help distinguish the event from other events
func NewPositionEvent ¶
func NewPositionEvent(collectionID int64, position model.Position) *PositionEvent
NewPositionEvent returns a new wrapped PositionEvent
func (*PositionEvent) EventType ¶
func (positionEvent *PositionEvent) EventType() EventType
EventType returns the Position event type
type PositionEventDetails ¶
type PositionEventDetails struct { CollectionID int64 `json:"collectionId"` TrackerID int64 `json:"trackerId"` Position model.Position `json:"position"` }
PositionEventDetails is a struct to be used for events triggered by a new position
type PublishableEvent ¶
type PublishableEvent interface {
EventType() EventType
}
PublishableEvent helps us have type safety on events that are publishable
type SubscriptionEvent ¶
type SubscriptionEvent struct { Type EventType `json:"type"` Data SubscriptionEventDetails `json:"data"` }
SubscriptionEvent wraps an event with a identifier to help
func NewSubscriptionEvent ¶
func NewSubscriptionEvent(subscriptionID int64, position model.Position, triggerDetails TriggerDetails) *SubscriptionEvent
NewSubscriptionEvent returns a new wrapped PositionEvent
func (*SubscriptionEvent) EventType ¶
func (subscriptionEvent *SubscriptionEvent) EventType() EventType
EventType returns the Subscription event type
type SubscriptionEventDetails ¶
type SubscriptionEventDetails struct { SubscriptionID int64 `json:"subscriptionId"` Position model.Position `json:"position"` Details TriggerDetails `json:"details"` }
SubscriptionEventDetails is a struct to be used for events triggered by a subscription
type TriggerDetails ¶
type TriggerDetails struct { Movements []string `json:"movements"` ShapecollectionID int64 `json:"shapecollectionId"` ShapeID int64 `json:"shapeId"` }
TriggerDetails contains information about why the subscription triggered along with IDs to shapecollection and shape