Documentation ¶
Overview ¶
Package direct provides a saga mapping strategy that maps messages to saga instances by having the saga implement a method that returns the instance ID directly.
Index ¶
- type Mapper
- func (m *Mapper) DeleteMapping(context.Context, saga.Saga, persistence.Tx, saga.Instance) error
- func (m *Mapper) MapMessageToInstance(_ context.Context, _ saga.Saga, _ persistence.Tx, env ax.Envelope) (saga.InstanceID, bool, error)
- func (m *Mapper) UpdateMapping(context.Context, saga.Saga, persistence.Tx, saga.Instance) error
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mapper ¶
type Mapper struct {
Resolver Resolver
}
Mapper is an implementation of saga.Mapper that maps messages to saga instances using only information contained in the message.
func ByField ¶
ByField returns a mapper that maps messages to instances using a set of fields within the message.
All fields must be strings. If any of the fields are empty, the message is not routed to any instance.
func WithPrefix ¶
WithPrefix returns a mapper that wraps around m and adds a prefix string to the instance ID returned by m's Resolver.
If m's Resolver does not return a valid instance ID, no prefix is added.
func (*Mapper) DeleteMapping ¶
DeleteMapping notifies the mapper that an instance has been completed, allowing it to remove it's mapping information, if necessary.
func (*Mapper) MapMessageToInstance ¶
func (m *Mapper) MapMessageToInstance( _ context.Context, _ saga.Saga, _ persistence.Tx, env ax.Envelope, ) (saga.InstanceID, bool, error)
MapMessageToInstance returns the ID of the saga instance that is the target of the given message.
It returns false if the message should be ignored.
type Resolver ¶
type Resolver interface { // InstanceIDForMessage returns the ID of the saga instance to which the // given message is routed, if any. // // If ok is false the message is ignored; otherwise, the message is routed // to the saga instance with the returned ID. InstanceIDForMessage(env ax.Envelope) (saga.InstanceID, bool) }
Resolver is an interface that provides the application-defined logic for mapping a message to its target saga instance.