Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicEvent ¶
type BasicEvent struct { EntityID string `json:"entity_id" bson:"entity_id"` EventID string `json:"event_id" bson:"event_id"` EventName string `json:"event_type" bson:"event_type"` CreatedAt time.Time `json:"created_at" bson:"created_at"` }
func NewBasicEvent ¶
func NewBasicEvent(entityID string, name string) BasicEvent
func (BasicEvent) GetCreatedAt ¶
func (basicEvent BasicEvent) GetCreatedAt() time.Time
func (BasicEvent) GetEntityID ¶
func (basicEvent BasicEvent) GetEntityID() string
func (BasicEvent) GetEventID ¶
func (basicEvent BasicEvent) GetEventID() string
func (BasicEvent) GetEventName ¶
func (basicEvent BasicEvent) GetEventName() string
type BasicProjection ¶
type BasicProjection struct { EntityID string `json:"entity_id" bson:"entity_id"` LastEventID string `json:"last_event_id" bson:"last_event_id"` LastEventTime time.Time `json:"last_event_time" bson:"last_event_time"` }
func (*BasicProjection) Apply ¶
func (basicProjection *BasicProjection) Apply(event Event)
func (BasicProjection) GetCollectionName ¶
func (BasicProjection) GetCollectionName() string
func (*BasicProjection) GetEntityID ¶
func (basicProjection *BasicProjection) GetEntityID() string
func (*BasicProjection) GetLastEventID ¶
func (basicProjection *BasicProjection) GetLastEventID() string
type BuildProjectionFunc ¶
type BuildProjectionFunc func(ctx context.Context, events []Event) (Projection, error)
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controllers are the primary way to save events and build projections based upon these.
func NewController ¶
func NewController(projection Projection, buildProjection BuildProjectionFunc, provider StorageProvider) *Controller
NewController creates a new instance of an controller by collection all necessary data.
func (*Controller) GetLatestProjection ¶
func (controller *Controller) GetLatestProjection(ctx context.Context, entityID string) (Projection, error)
GetLatestProjection retrieves the latest projection the managed projection-entity.
type Projection ¶
type Projection interface { Apply(Event) GetCollectionName() string GetEntityID() string GetLastEventID() string }
func BasicProjectionGenerator ¶
func BasicProjectionGenerator(result *mongo.SingleResult) (Projection, error)
type StorageProvider ¶
type StorageProvider interface { SaveEvent(ctx context.Context, event Event) error SaveProjection(ctx context.Context, projection Projection) error GetProjection(ctx context.Context, entityID string, projection Projection) (Projection, error) GetLatestEventIDForEntityID(ctx context.Context, entityID string) (string, error) GetSortedEventsForEntityID(ctx context.Context, entityID string) ([]Event, error) }
Click to show internal directories.
Click to hide internal directories.