Documentation
¶
Index ¶
- Constants
- func ContextOne(ctx context.Context) (string, bool)
- func WithContextOne(ctx context.Context, val string) context.Context
- type Aggregate
- type AggregateStore
- type Command
- type CommandHandler
- type CommandOther
- type CommandOther2
- type EmptyAggregate
- type EventBus
- type EventData
- type EventHandler
- type EventStore
- func (m *EventStore) Close() error
- func (m *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)
- func (m *EventStore) LoadFrom(ctx context.Context, id uuid.UUID, version int) ([]eh.Event, error)
- func (m *EventStore) LoadSnapshot(ctx context.Context, id uuid.UUID) (*eh.Snapshot, error)
- func (m *EventStore) LoadUntil(ctx context.Context, id uuid.UUID, version int) ([]eh.Event, error)
- func (m *EventStore) Replace(ctx context.Context, event eh.Event) error
- func (m *EventStore) Save(ctx context.Context, events []eh.Event, originalVersion int) error
- func (m *EventStore) SaveSnapshot(ctx context.Context, id uuid.UUID, snapshot eh.Snapshot) error
- type Model
- type Repo
- func (r *Repo) Close() error
- func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)
- func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error)
- func (r *Repo) InnerRepo(ctx context.Context) eh.ReadRepo
- func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error
- func (r *Repo) Save(ctx context.Context, entity eh.Entity) error
- type SimpleModel
Constants ¶
const ( // AggregateType is the type for Aggregate. AggregateType eh.AggregateType = "Aggregate" // EventType is a the type for Event. EventType eh.EventType = "Event" // EventOtherType is the type for EventOther. EventOtherType eh.EventType = "EventOther" // CommandType is the type for Command. CommandType eh.CommandType = "Command" // CommandOtherType is the type for CommandOther. CommandOtherType eh.CommandType = "CommandOther" // CommandOther2Type is the type for CommandOther2. CommandOther2Type eh.CommandType = "CommandOther2" )
Variables ¶
This section is empty.
Functions ¶
func ContextOne ¶
ContextOne returns a value for One from the context.
Types ¶
type Aggregate ¶
type Aggregate struct {
ID uuid.UUID
Commands []eh.Command
Context context.Context
// Used to simulate errors in HandleCommand.
Err error
}
Aggregate is a mocked eventhorizon.Aggregate, useful in testing.
func NewAggregate ¶
NewAggregate returns a new Aggregate.
func (*Aggregate) AggregateType ¶
func (a *Aggregate) AggregateType() eh.AggregateType
AggregateType implements the AggregateType method of the eventhorizon.Aggregate interface.
func (*Aggregate) ApplySnapshot ¶ added in v0.18.0
func (*Aggregate) CreateSnapshot ¶ added in v0.18.0
type AggregateStore ¶
type AggregateStore struct {
Aggregates map[uuid.UUID]eh.Aggregate
Snapshots map[uuid.UUID]eh.Snapshot
Context context.Context
// Used to simulate errors in HandleCommand.
Err error
}
AggregateStore is a mocked AggregateStore, useful in testing.
func (*AggregateStore) Load ¶
func (m *AggregateStore) Load(ctx context.Context, aggregateType eh.AggregateType, id uuid.UUID) (eh.Aggregate, error)
Load implements the Load method of the eventhorizon.AggregateStore interface.
func (*AggregateStore) Save ¶
Save implements the Save method of the eventhorizon.AggregateStore interface.
func (*AggregateStore) TakeSnapshot ¶ added in v0.18.0
type Command ¶
Command is a mocked eventhorizon.Command, useful in testing.
func (Command) AggregateID ¶
func (Command) AggregateType ¶
func (t Command) AggregateType() eh.AggregateType
func (Command) CommandType ¶
func (t Command) CommandType() eh.CommandType
type CommandHandler ¶
type CommandHandler struct {
sync.RWMutex
Commands []eh.Command
Context context.Context
// Used to simulate errors when handling.
Err error
}
CommandHandler is a mocked eventhorizon.CommandHandler, useful in testing.
func (*CommandHandler) HandleCommand ¶
HandleCommand implements the HandleCommand method of the eventhorizon.CommandHandler interface.
type CommandOther ¶
CommandOther is a mocked eventhorizon.Command, useful in testing.
func (CommandOther) AggregateID ¶
func (t CommandOther) AggregateID() uuid.UUID
func (CommandOther) AggregateType ¶
func (t CommandOther) AggregateType() eh.AggregateType
func (CommandOther) CommandType ¶
func (t CommandOther) CommandType() eh.CommandType
type CommandOther2 ¶
CommandOther2 is a mocked eventhorizon.Command, useful in testing.
func (CommandOther2) AggregateID ¶
func (t CommandOther2) AggregateID() uuid.UUID
func (CommandOther2) AggregateType ¶
func (t CommandOther2) AggregateType() eh.AggregateType
func (CommandOther2) CommandType ¶
func (t CommandOther2) CommandType() eh.CommandType
type EventBus ¶
type EventBus struct {
Events []eh.Event
Context context.Context
// Used to simulate errors in PublishEvent.
Err error
}
EventBus is a mocked eventhorizon.EventBus, useful in testing.
func (*EventBus) AddHandler ¶
func (b *EventBus) AddHandler(ctx context.Context, m eh.EventMatcher, h eh.EventHandler) error
AddHandler implements the AddHandler method of the eventhorizon.EventBus interface.
func (*EventBus) Close ¶ added in v0.18.0
Close implements the Close method of the eventhorizon.EventBus interface.
func (*EventBus) Errors ¶ added in v0.18.0
Errors implements the Errors method of the eventhorizon.EventBus interface.
func (*EventBus) HandleEvent ¶ added in v0.18.0
HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface.
func (*EventBus) HandlerType ¶ added in v0.18.0
func (b *EventBus) HandlerType() eh.EventHandlerType
HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.
type EventData ¶
type EventData struct {
Content string
}
EventData is a mocked event data, useful in testing.
type EventHandler ¶
type EventHandler struct {
sync.RWMutex
Type string
Events []eh.Event
Context context.Context
Time time.Time
Recv chan eh.Event
// Used to simulate errors when publishing.
Err error
}
EventHandler is a mocked eventhorizon.EventHandler, useful in testing.
func NewEventHandler ¶
func NewEventHandler(handlerType string) *EventHandler
NewEventHandler creates a new EventHandler.
func (*EventHandler) HandleEvent ¶
HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface.
func (*EventHandler) HandlerType ¶ added in v0.18.0
func (m *EventHandler) HandlerType() eh.EventHandlerType
HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.
type EventStore ¶
type EventStore struct {
Events []eh.Event
Snapshot eh.Snapshot
Loaded uuid.UUID
Context context.Context
// Used to simulate errors in the store.
Err error
}
EventStore is a mocked eventhorizon.EventStore, useful in testing.
func (*EventStore) Close ¶ added in v0.18.0
func (m *EventStore) Close() error
Close implements the Close method of the eventhorizon.EventStore interface.
func (*EventStore) LoadFrom ¶ added in v0.18.0
LoadFrom loads all events from version for the aggregate id from the store.
func (*EventStore) LoadSnapshot ¶ added in v0.18.0
func (*EventStore) LoadUntil ¶ added in v0.21.0
LoadUntil loads all events until version for the aggregate id from the store.
func (*EventStore) Replace ¶
Replace implements the Replace method of the eventhorizon.EventStore interface.
func (*EventStore) SaveSnapshot ¶ added in v0.18.0
type Model ¶
type Model struct {
ID uuid.UUID `json:"id" bson:"_id"`
Version int `json:"version" bson:"version"`
Content string `json:"content" bson:"content"`
CreatedAt time.Time `json:"created_at" bson:"created_at"`
}
Model is a mocked read model, useful in testing.
func (*Model) AggregateVersion ¶
AggregateVersion implements the AggregateVersion method of the eventhorizon.Versionable interface.
type Repo ¶
type Repo struct {
sync.RWMutex
ParentRepo eh.ReadWriteRepo
Entity eh.Entity
Entities []eh.Entity
// Used to simulate errors in the store.
LoadErr, SaveErr error
FindCalled, FindAllCalled, SaveCalled, RemoveCalled bool
}
Repo is a mocked eventhorizon.ReadRepo, useful in testing.
func (*Repo) Close ¶ added in v0.18.0
Close implements the Close method of the eventhorizon.ReadRepo interface.
func (*Repo) FindAll ¶
FindAll implements the FindAll method of the eventhorizon.ReadRepo interface.
func (*Repo) InnerRepo ¶ added in v0.18.0
InnerRepo implements the InnerRepo method of the eventhorizon.ReadRepo interface.
type SimpleModel ¶
type SimpleModel struct {
ID uuid.UUID `json:"id" bson:"_id"`
Content string `json:"content" bson:"content"`
}
SimpleModel is a mocked read model, useful in testing, without a version.
func (*SimpleModel) EntityID ¶
func (m *SimpleModel) EntityID() uuid.UUID
EntityID implements the EntityID method of the eventhorizon.Entity interface.