Documentation
¶
Overview ¶
Package handler provides utilities for working with Dogma message handlers.
Index ¶
- Variables
- type EmptyInstanceIDError
- type EventNotRecordedError
- type NilRootError
- type Type
- func (t Type) Consumes() []message.Role
- func (t Type) Is(types ...Type) bool
- func (t Type) IsConsumerOf(r message.Role) bool
- func (t Type) IsProducerOf(r message.Role) bool
- func (t Type) MustBe(types ...Type)
- func (t Type) MustNotBe(types ...Type)
- func (t Type) MustValidate()
- func (t Type) Produces() []message.Role
- func (t Type) ShortString() string
- func (t Type) String() string
- func (t Type) Validate() error
- type UnexpectedMessageError
Constants ¶
This section is empty.
Variables ¶
var Types = []Type{ AggregateType, ProcessType, IntegrationType, ProjectionType, }
Types is a slice of the valid handler types.
Functions ¶
This section is empty.
Types ¶
type EmptyInstanceIDError ¶
type EmptyInstanceIDError struct {
// Handler is the identity of the handler that caused the error.
Handler identity.Identity
// HandlerType is the type of handler that caused the error.
HandlerType Type
// Message is the message that was being handled when the error occurred.
Message dogma.Message
}
EmptyInstanceIDError indicates that an aggregate or process message handler has attempted to route a message to an instance with an empty ID.
func (EmptyInstanceIDError) Error ¶
func (e EmptyInstanceIDError) Error() string
type EventNotRecordedError ¶
type EventNotRecordedError struct {
// Handler is the identity of the handler that caused the error.
Handler identity.Identity
// WasDestroyed is true if the error occurred as a result of the description
// of an aggregate, as opposed to creation.
WasDestroyed bool
// Message is the message that was being handled when the error occurred.
Message dogma.Message
// InstanceID is the aggregate instance ID that the message was routed to.
InstanceID string
}
EventNotRecordedError indicates that an aggregate instance was created or destroyed without recording an event.
func (EventNotRecordedError) Error ¶
func (e EventNotRecordedError) Error() string
type NilRootError ¶
type NilRootError struct {
// Handler is the identity of the handler that caused the error.
Handler identity.Identity
// HandlerType is the type of handler that caused the error.
HandlerType Type
}
NilRootError indicates that an aggregate or process message handler has returned a nil "root" value from its New() method.
func (NilRootError) Error ¶
func (e NilRootError) Error() string
type Type ¶
type Type string
Type is an enumeration of the types of handlers.
const ( // AggregateType is the handler type for dogma.AggregateMessageHandler. AggregateType Type = "aggregate" // ProcessType is the handler type for dogma.ProcessMessageHandler. ProcessType Type = "process" // IntegrationType is the handler type for dogma.IntegrationMessageHandler. IntegrationType Type = "integration" // ProjectionType is the handler type for dogma.ProjectionMessageHandler. ProjectionType Type = "projection" )
func ConsumersOf ¶
ConsumersOf returns the handler types that can consume messages with the given role.
func ProducersOf ¶
ProducersOf returns the handler types that can produces messages with the given role.
func (Type) Consumes ¶
Consumes returns the roles of messages that can be consumed by handlers of this type.
func (Type) IsConsumerOf ¶
IsConsumerOf returns true if handlers of type t can consume messages with the given role.
func (Type) IsProducerOf ¶
IsProducerOf returns true if handlers of type t can produce messages with the given role.
func (Type) MustValidate ¶
func (t Type) MustValidate()
MustValidate panics if r is not a valid message role.
func (Type) Produces ¶
Produces returns the roles of messages that can be produced by handlers of this type.
func (Type) ShortString ¶
ShortString returns a short (3-character) representation of the handler type.
type UnexpectedMessageError ¶ added in v0.7.0
type UnexpectedMessageError struct {
// Handler is the identity of the handler that caused the error.
Handler identity.Identity
// HandlerType is the type of handler that caused the error.
HandlerType Type
// Message is the message that was being handled when the error occurred.
Message dogma.Message
// InstanceID is the aggregate instance ID that the message was routed to.
// It is empty if HandleType is not AggregateType or ProcessType, or
// otherwise if the error occurred outside the context of any specific
// instance.
InstanceID string
// StackTrace is the result of debug.Stack(), captured while recovering from
// the panic.
StackTrace []byte
}
UnexpectedMessageError indicates that a message handler has panicked with a dogma.UnexpectedMessage value.
func (UnexpectedMessageError) Error ¶ added in v0.7.0
func (e UnexpectedMessageError) Error() string