axdogma

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateAdaptor

type AggregateAdaptor struct {
	saga.IgnoreNotFound

	Name         string
	CommandTypes ax.MessageTypeSet
	Handler      dogma.AggregateMessageHandler
	// contains filtered or unexported fields
}

AggregateAdaptor adapts a dogma.AggregateMessageHandler to Ax's saga.Saga interface.

func (*AggregateAdaptor) ApplyEvent

func (a *AggregateAdaptor) ApplyEvent(d saga.Data, env ax.Envelope)

ApplyEvent updates d to reflect the fact that an event has occurred.

It may panic if env.Message does not implement ax.Event.

func (*AggregateAdaptor) HandleMessage

func (a *AggregateAdaptor) HandleMessage(
	ctx context.Context,
	s ax.Sender,
	mctx ax.MessageContext,
	i saga.Instance,
) (err error)

HandleMessage handles a message for a particular saga instance.

func (*AggregateAdaptor) IsInstanceComplete

func (a *AggregateAdaptor) IsInstanceComplete(ctx context.Context, i saga.Instance) (bool, error)

IsInstanceComplete returns true if the given instance is complete.

func (*AggregateAdaptor) MessageTypes

func (a *AggregateAdaptor) MessageTypes() (tr ax.MessageTypeSet, mt ax.MessageTypeSet)

MessageTypes returns the set of messages that are routed to this saga.

tr is the set of "trigger" messages. If they can not be routed to an existing saga instance a new instance is created.

mt is the set of messages that are only routed to existing instances. If they can not be routed to an existing instance, the HandleNotFound() method is called instead.

func (*AggregateAdaptor) NewData

func (a *AggregateAdaptor) NewData() saga.Data

NewData returns a pointer to a new zero-value instance of the saga's data type.

func (*AggregateAdaptor) PersistenceKey

func (a *AggregateAdaptor) PersistenceKey() string

PersistenceKey returns a unique identifier for the saga.

The persistence key is used to relate persisted data with the saga implementation that owns it. Persistence keys should not be changed once a saga has active instances.

type AggregateMapper

type AggregateMapper struct{}

AggregateMapper is a saga.Mapper that maps messages to instances using a Dogma aggregate's RouteCommandToInstance() method.

func (*AggregateMapper) DeleteMapping

DeleteMapping notifies the mapper that an instance has been completed, allowing it to remove it's mapping information, if necessary.

func (*AggregateMapper) MapMessageToInstance

func (m *AggregateMapper) MapMessageToInstance(
	_ context.Context,
	sg 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.

func (*AggregateMapper) UpdateMapping

UpdateMapping notifies the mapper that an instance has been modified, allowing it to update it's mapping information, if necessary.

type App

type App struct {
	Aggregates   []saga.Saga
	Processes    []saga.Saga
	Integrations []routing.MessageHandler
	Projections  []projection.Projector
}

App contains Dogma application components adapted to Ax interfaces.

func New

func New(app dogma.Application) (*App, error)

New returns a structure that contains a Dogma application's aggregates, processes, integrations and projections adapted into the most appropriate Ax type.

type IntegrationAdaptor

type IntegrationAdaptor struct {
	CommandTypes ax.MessageTypeSet
	Handler      dogma.IntegrationMessageHandler
}

IntegrationAdaptor adapts a dogma.IntegrationMessageHandler to Ax's routing.MessageHandler interface.

func (*IntegrationAdaptor) HandleMessage

func (a *IntegrationAdaptor) HandleMessage(
	ctx context.Context,
	s ax.Sender,
	mctx ax.MessageContext,
) error

HandleMessage invokes application-defined logic that handles a message.

It may panic if env.Message is not one of the types described by MessageTypes().

func (*IntegrationAdaptor) MessageTypes

func (a *IntegrationAdaptor) MessageTypes() ax.MessageTypeSet

MessageTypes returns the set of messages that the handler intends to handle.

The return value should be constant as it may be cached by various independent stages in the message pipeline.

type ProcessAdaptor

type ProcessAdaptor struct {
	saga.IgnoreNotFound

	Name       string
	EventTypes ax.MessageTypeSet
	Handler    dogma.ProcessMessageHandler
	// contains filtered or unexported fields
}

ProcessAdaptor adapts a dogma.ProcessMessageHandler to Ax's saga.Saga interface.

func (*ProcessAdaptor) HandleMessage

func (a *ProcessAdaptor) HandleMessage(
	ctx context.Context,
	s ax.Sender,
	mctx ax.MessageContext,
	i saga.Instance,
) (err error)

HandleMessage handles a message for a particular saga instance.

func (*ProcessAdaptor) IsInstanceComplete

func (a *ProcessAdaptor) IsInstanceComplete(ctx context.Context, i saga.Instance) (bool, error)

IsInstanceComplete returns true if the given instance is complete.

func (*ProcessAdaptor) MessageTypes

func (a *ProcessAdaptor) MessageTypes() (tr ax.MessageTypeSet, mt ax.MessageTypeSet)

MessageTypes returns the set of messages that are routed to this saga.

tr is the set of "trigger" messages. If they can not be routed to an existing saga instance a new instance is created.

mt is the set of messages that are only routed to existing instances. If they can not be routed to an existing instance, the HandleNotFound() method is called instead.

func (*ProcessAdaptor) NewData

func (a *ProcessAdaptor) NewData() saga.Data

NewData returns a pointer to a new zero-value instance of the saga's data type.

func (*ProcessAdaptor) PersistenceKey

func (a *ProcessAdaptor) PersistenceKey() string

PersistenceKey returns a unique identifier for the saga.

The persistence key is used to relate persisted data with the saga implementation that owns it. Persistence keys should not be changed once a saga has active instances.

type ProcessMapper

type ProcessMapper struct{}

ProcessMapper is a saga.Mapper that maps messages to instances using a Dogma aggregate's RouteCommandToInstance() method.

func (*ProcessMapper) DeleteMapping

DeleteMapping notifies the mapper that an instance has been completed, allowing it to remove it's mapping information, if necessary.

func (*ProcessMapper) MapMessageToInstance

func (m *ProcessMapper) MapMessageToInstance(
	ctx context.Context,
	sg 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.

func (*ProcessMapper) UpdateMapping

UpdateMapping notifies the mapper that an instance has been modified, allowing it to update it's mapping information, if necessary.

type ProjectionAdaptor

type ProjectionAdaptor struct {
	Name       string
	EventTypes ax.MessageTypeSet
	Handler    dogma.ProjectionMessageHandler
}

ProjectionAdaptor adapts a dogma.ProjectionMessageHandler to Ax's projection.Projector interface.

func (*ProjectionAdaptor) ApplyMessage

func (a *ProjectionAdaptor) ApplyMessage(ctx context.Context, mctx ax.MessageContext) error

ApplyMessage invokes application-defined logic that updates the application state to reflect the occurrence of a message.

It may panic if env.Message is not one of the types described by MessageTypes().

func (*ProjectionAdaptor) MessageTypes

func (a *ProjectionAdaptor) MessageTypes() ax.MessageTypeSet

MessageTypes returns the set of messages that the projector intends to handle.

The return value should be constant as it may be cached.

func (*ProjectionAdaptor) PersistenceKey

func (a *ProjectionAdaptor) PersistenceKey() string

PersistenceKey returns a unique name for the projector.

The persistence key is used to relate persisted data with the projector implementation that owns it. Persistence keys should not be changed once a projection has been started.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL