event

package
v0.0.0-...-ae1d368 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

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 EventType

type EventType string

EventType defines which type of event the event consist of

const (
	// LifeCycle represents the lifecycle event type
	LifeCycle EventType = "lifecycle"
	// Position represents the position event type
	Position EventType = "position"
	// Subscription represents the subscription event type
	Subscription EventType = "subscription"
)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL