Help us shape the future of Go! Take the 2026 Go Developer Survey

handler

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package handler provides utilities for working with Dogma message handlers.

Index

Constants

This section is empty.

Variables

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

func ConsumersOf(r message.Role) []Type

ConsumersOf returns the handler types that can consume messages with the given role.

func ProducersOf

func ProducersOf(r message.Role) []Type

ProducersOf returns the handler types that can produces messages with the given role.

func (Type) Consumes

func (t Type) Consumes() []message.Role

Consumes returns the roles of messages that can be consumed by handlers of this type.

func (Type) Is

func (t Type) Is(types ...Type) bool

Is returns true if t is one of the given types.

func (Type) IsConsumerOf

func (t Type) IsConsumerOf(r message.Role) bool

IsConsumerOf returns true if handlers of type t can consume messages with the given role.

func (Type) IsProducerOf

func (t Type) IsProducerOf(r message.Role) bool

IsProducerOf returns true if handlers of type t can produce messages with the given role.

func (Type) MustBe

func (t Type) MustBe(types ...Type)

MustBe panics if t is not one of the given types.

func (Type) MustNotBe

func (t Type) MustNotBe(types ...Type)

MustNotBe panics if t is one of the given types.

func (Type) MustValidate

func (t Type) MustValidate()

MustValidate panics if r is not a valid message role.

func (Type) Produces

func (t Type) Produces() []message.Role

Produces returns the roles of messages that can be produced by handlers of this type.

func (Type) ShortString

func (t Type) ShortString() string

ShortString returns a short (3-character) representation of the handler type.

func (Type) String

func (t Type) String() string

func (Type) Validate added in v0.5.1

func (t Type) Validate() error

Validate returns an error if r is not a valid message role.

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

Jump to

Keyboard shortcuts

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