Documentation
¶
Overview ¶
Package fixtures is a set of test fixtures and mocks of the various types.
Index ¶
- Constants
- func NewEnvelope(id string, m dogma.Message, times ...time.Time) *envelopespec.Envelope
- func NewPacker(roles message.TypeRoles) *parcel.Packer
- func NewParcel(id string, m dogma.Message, times ...time.Time) parcel.Parcel
- type AcknowledgerStub
- type DataStoreStub
- func (ds *DataStoreStub) Close() error
- func (ds *DataStoreStub) LoadAggregateMetaData(ctx context.Context, hk, id string) (persistence.AggregateMetaData, error)
- func (ds *DataStoreStub) LoadEventsBySource(ctx context.Context, hk, id, d string) (persistence.EventResult, error)
- func (ds *DataStoreStub) LoadEventsByType(ctx context.Context, f map[string]struct{}, o uint64) (persistence.EventResult, error)
- func (ds *DataStoreStub) LoadOffset(ctx context.Context, ak string) (uint64, error)
- func (ds *DataStoreStub) LoadProcessInstance(ctx context.Context, hk, id string) (persistence.ProcessInstance, error)
- func (ds *DataStoreStub) LoadQueueMessages(ctx context.Context, n int) ([]persistence.QueueMessage, error)
- func (ds *DataStoreStub) Persist(ctx context.Context, b persistence.Batch) (persistence.Result, error)
- type EventResultStub
- type EventStreamHandlerStub
- type EventStreamStub
- type HandlerStub
- type ProviderStub
- type UnitOfWorkStub
- func (w *UnitOfWorkStub) Defer(fn handler.DeferFunc)
- func (w *UnitOfWorkStub) Do(op persistence.Operation)
- func (w *UnitOfWorkStub) ExecuteCommand(p parcel.Parcel)
- func (w *UnitOfWorkStub) Fail(err error)
- func (w *UnitOfWorkStub) RecordEvent(p parcel.Parcel)
- func (w *UnitOfWorkStub) ScheduleTimeout(p parcel.Parcel)
- func (w *UnitOfWorkStub) Succeed(res handler.Result)
Constants ¶
const ( // DefaultAppKey is the default application key for test envelopes. DefaultAppKey = "a96fefa1-2630-467a-b756-db2e428a56fd" // DefaultHandlerKey is the default handler key for test envelopes. DefaultHandlerKey = "16c7843f-c94f-4fd1-ba80-fd59cab793ff" )
Variables ¶
This section is empty.
Functions ¶
func NewEnvelope ¶
NewEnvelope returns a new envelope containing the given message.
If id is empty, a new UUID is generated.
times can contain up to two elements, the first is the created time, the second is the scheduled-for time.
func NewPacker ¶
NewPacker returns a parcel packer that uses a deterministic ID sequence and clock.
MessageID is a monotonically increasing integer, starting at 0. CreatedAt starts at 2000-01-01 00:00:00 UTC and increases by 1 second for each message.
The given roles are valid both as produced and consumed roles.
Types ¶
type AcknowledgerStub ¶
type AcknowledgerStub struct { handler.Acknowledger AckFunc func(context.Context, persistence.Batch) (persistence.Result, error) NackFunc func(context.Context, error) error }
AcknowledgerStub is a test implementation of the handler.Acknowledger interface.
func (*AcknowledgerStub) Ack ¶
func (a *AcknowledgerStub) Ack(ctx context.Context, b persistence.Batch) (persistence.Result, error)
Ack acknowledges the message, ensuring it is not handled again.
b is the batch from the unit-of-work.
type DataStoreStub ¶
type DataStoreStub struct { persistence.DataStore LoadAggregateMetaDataFunc func(context.Context, string, string) (persistence.AggregateMetaData, error) LoadEventsByTypeFunc func(context.Context, map[string]struct{}, uint64) (persistence.EventResult, error) LoadEventsBySourceFunc func(context.Context, string, string, string) (persistence.EventResult, error) LoadOffsetFunc func(context.Context, string) (uint64, error) LoadProcessInstanceFunc func(context.Context, string, string) (persistence.ProcessInstance, error) LoadQueueMessagesFunc func(context.Context, int) ([]persistence.QueueMessage, error) PersistFunc func(context.Context, persistence.Batch) (persistence.Result, error) CloseFunc func() error }
DataStoreStub is a test implementation of the persistence.DataStore interface.
func NewDataStoreStub ¶
func NewDataStoreStub() *DataStoreStub
NewDataStoreStub returns a new data-store stub that uses an in-memory persistence provider.
func (*DataStoreStub) LoadAggregateMetaData ¶
func (ds *DataStoreStub) LoadAggregateMetaData( ctx context.Context, hk, id string, ) (persistence.AggregateMetaData, error)
LoadAggregateMetaData loads the meta-data for an aggregate instance.
func (*DataStoreStub) LoadEventsBySource ¶
func (ds *DataStoreStub) LoadEventsBySource( ctx context.Context, hk, id, d string, ) (persistence.EventResult, error)
LoadEventsBySource loads the events produced by a specific handler.
func (*DataStoreStub) LoadEventsByType ¶
func (ds *DataStoreStub) LoadEventsByType( ctx context.Context, f map[string]struct{}, o uint64, ) (persistence.EventResult, error)
LoadEventsByType loads events that match a specific set of message types.
func (*DataStoreStub) LoadOffset ¶
LoadOffset loads the offset associated with a specific application.
func (*DataStoreStub) LoadProcessInstance ¶
func (ds *DataStoreStub) LoadProcessInstance( ctx context.Context, hk, id string, ) (persistence.ProcessInstance, error)
LoadProcessInstance loads a process instance.
func (*DataStoreStub) LoadQueueMessages ¶
func (ds *DataStoreStub) LoadQueueMessages( ctx context.Context, n int, ) ([]persistence.QueueMessage, error)
LoadQueueMessages loads the next n messages from the queue.
func (*DataStoreStub) Persist ¶
func (ds *DataStoreStub) Persist(ctx context.Context, b persistence.Batch) (persistence.Result, error)
Persist commits a batch of operations atomically.
type EventResultStub ¶
type EventResultStub struct { persistence.EventResult NextFunc func(context.Context) (persistence.Event, bool, error) CloseFunc func() error }
EventResultStub is a test implementation of the persistence.EventResult interface.
func (*EventResultStub) Next ¶
func (r *EventResultStub) Next(ctx context.Context) (persistence.Event, bool, error)
Next returns the next event in the result.
type EventStreamHandlerStub ¶
type EventStreamHandlerStub struct { eventstream.Handler NextOffsetFunc func(context.Context, configkit.Identity) (uint64, error) HandleEventFunc func(context.Context, uint64, eventstream.Event) error }
EventStreamHandlerStub is a test implementation of the eventstream.Handler interface.
func (*EventStreamHandlerStub) HandleEvent ¶
func (h *EventStreamHandlerStub) HandleEvent( ctx context.Context, o uint64, ev eventstream.Event, ) error
HandleEvent handles an event obtained from the event stream.
func (*EventStreamHandlerStub) NextOffset ¶
func (h *EventStreamHandlerStub) NextOffset( ctx context.Context, id configkit.Identity, ) (uint64, error)
NextOffset returns the offset of the next event to be consumed from a specific application's event stream.
type EventStreamStub ¶
type EventStreamStub struct { eventstream.Stream ApplicationFunc func() configkit.Identity EventTypesFunc func(context.Context) (message.TypeCollection, error) OpenFunc func(context.Context, uint64, message.TypeCollection) (eventstream.Cursor, error) }
EventStreamStub is a test implementation of the eventstream.Stream interface.
func (*EventStreamStub) Application ¶
func (s *EventStreamStub) Application() configkit.Identity
Application returns the identity of the application that owns the stream.
func (*EventStreamStub) EventTypes ¶
func (s *EventStreamStub) EventTypes(ctx context.Context) (message.TypeCollection, error)
EventTypes returns the set of event types that may appear on the stream.
func (*EventStreamStub) Open ¶
func (s *EventStreamStub) Open( ctx context.Context, offset uint64, types message.TypeCollection, ) (eventstream.Cursor, error)
Open returns a cursor that reads events from the stream.
type HandlerStub ¶
type HandlerStub struct { handler.Handler HandleMessageFunc func(context.Context, handler.UnitOfWork, parcel.Parcel) error }
HandlerStub is a test implementation of the handler.Provider interface.
func (*HandlerStub) HandleMessage ¶
func (h *HandlerStub) HandleMessage(ctx context.Context, w handler.UnitOfWork, p parcel.Parcel) error
HandleMessage handles the message in p.
type ProviderStub ¶
type ProviderStub struct { persistence.Provider OpenFunc func(context.Context, string) (persistence.DataStore, error) }
ProviderStub is a test implementation of the persistence.Provider interface.
func (*ProviderStub) Open ¶
func (p *ProviderStub) Open(ctx context.Context, k string) (persistence.DataStore, error)
Open returns a data-store for a specific application.
type UnitOfWorkStub ¶
type UnitOfWorkStub struct { Commands []parcel.Parcel Events []parcel.Parcel Timeouts []parcel.Parcel Operations []persistence.Operation Deferred []handler.DeferFunc }
UnitOfWorkStub is a test implementation of the handler.UnitOfWork interface.
func (*UnitOfWorkStub) Defer ¶
func (w *UnitOfWorkStub) Defer(fn handler.DeferFunc)
Defer registers fn to be called when the unit-of-work is complete.
func (*UnitOfWorkStub) Do ¶
func (w *UnitOfWorkStub) Do(op persistence.Operation)
Do updates the unit-of-work to include op in the persistence batch.
func (*UnitOfWorkStub) ExecuteCommand ¶
func (w *UnitOfWorkStub) ExecuteCommand(p parcel.Parcel)
ExecuteCommand updates the unit-of-work to execute the command in p.
func (*UnitOfWorkStub) Fail ¶
func (w *UnitOfWorkStub) Fail(err error)
Fail invokes the unit-of-work's deferred functions with the given error.
func (*UnitOfWorkStub) RecordEvent ¶
func (w *UnitOfWorkStub) RecordEvent(p parcel.Parcel)
RecordEvent updates the unit-of-work to record the event in p.
func (*UnitOfWorkStub) ScheduleTimeout ¶
func (w *UnitOfWorkStub) ScheduleTimeout(p parcel.Parcel)
ScheduleTimeout updates the unit-of-work to schedule the timeout in p.
func (*UnitOfWorkStub) Succeed ¶
func (w *UnitOfWorkStub) Succeed(res handler.Result)
Succeed invokes the unit-of-work's deferred functions with the given result.