Documentation
¶
Index ¶
- Constants
- Variables
- func AssignProjectorID(name string, offsetRepo *mongodb.Repo) int32
- func Reset(ctx context.Context, repoOutbox *mongodb.Repo, repoOffset *mongodb.Repo) error
- type DefaultConverter
- type EventOutbox
- type HoldOutboxEvent
- type IConverter
- type IOutbox
- type IProjector
- type ReadProjectorGroup
Constants ¶
const ( Stopped = 0 Paused = 1 Running = 2 )
Possible worker states.
Variables ¶
var ( // ErrInvalidEventData error returned when a events data is invalid ErrInvalidEventData = errors.New("Invalid Event data") // ErrConvertToExternalEvent error returned when converter fails to convert internal event to external event ErrConvertToExternalEvent = errors.New("Failed !! to convert to external event") // ErrSkipThisEvent error returned when custom converter skip this event, while pulishing to read side. ErrSkipThisEvent = errors.New("Info !! event skipped by converter implementation") // ErrProjectorNotInitialized error returned when a projector object not been initialized properly. ErrProjectorNotInitialized = errors.New("Error !! projector not initiallized") )
Functions ¶
func AssignProjectorID ¶
AssignProjectorID will assign a bit position to the concrete projector at the time of projector registration
Types ¶
type DefaultConverter ¶
type DefaultConverter struct { }
DefaultConverter to publish the internal event as it is
func (*DefaultConverter) ConvertToExternalEvent ¶
func (d *DefaultConverter) ConvertToExternalEvent(ctx context.Context, event eh.Event) (interface{}, error)
ConvertToExternalEvent for defautlt converter
type EventOutbox ¶
type EventOutbox struct { InProg int32 `json:"inProg" bson:"inProg"` Done int32 `json:"done" bson:"done"` EventType eh.EventType `json:"event_type" bson:"event_type"` Data interface{} `json:"data" bson:"data"` Timestamp time.Time `json:"timestamp" bson:"timestamp"` }
EventOutbox is helper to write the events to outbox
func (*EventOutbox) SaveToOutbox ¶
func (eventOutbox *EventOutbox) SaveToOutbox(ctx context.Context, repo *mongodb.Repo, id interface{}, eventType eh.EventType) error
SaveToOutbox save events to outbox.
type HoldOutboxEvent ¶
type HoldOutboxEvent struct { ID bson.ObjectId `json:"_id" bson:"_id,omitempty"` InProg int32 `json:"inProg" bson:"inProg"` Done int32 `json:"done" bson:"done"` EventType eh.EventType `json:"event_type" bson:"event_type"` Data interface{} `json:"data" bson:"data"` Timestamp time.Time `json:"timestamp" bson:"timestamp"` }
HoldOutboxEvent is helper to read scan events from outbox.
func (*HoldOutboxEvent) FindAndModify ¶
func (holdEvent *HoldOutboxEvent) FindAndModify(ctx context.Context, repo *mongodb.Repo, filter bson.M, change mgo.Change) error
FindAndModify to read a event from outbox follwing filter and change rules. Need ckt breaker to save db call incase there is no more event to be scan by projector
type IConverter ¶
type IConverter interface {
ConvertToExternalEvent(ctx context.Context, event eh.Event) (interface{}, error)
}
IConverter is to inject logic to convert internal to external event
type IOutbox ¶
type IOutbox interface {
FindAndModify(ctx context.Context, repo *mongodb.Repo, filter bson.M, change mgo.Change) error
}
IOutbox interface to scan events from outbox.
type IProjector ¶
type IProjector interface { Name() string Bit() int32 AssignProjectorID(offsetRepo *mongodb.Repo) OutboxRepo() *mongodb.Repo OffsetRepo() *mongodb.Repo Converter() IConverter WriteToReadside(ctx context.Context, key string, data interface{}) error }
IProjector is the interface for all the projector
type ReadProjectorGroup ¶
type ReadProjectorGroup struct {
// contains filtered or unexported fields
}
ReadProjectorGroup is collection of iWorker
func GetReadProjectorGroup ¶
func GetReadProjectorGroup() *ReadProjectorGroup
GetReadProjectorGroup get the singleton object of ReadProjectorGroup
func (*ReadProjectorGroup) RegisterProjector ¶
func (rpg *ReadProjectorGroup) RegisterProjector(p IProjector)
RegisterProjector to register a new readside projector
func (*ReadProjectorGroup) Start ¶
func (rpg *ReadProjectorGroup) Start()
Start all the projector worker