Documentation
¶
Overview ¶
Package message provides utilities for representing information about Dogma messages and their use within an application.
Deprecated: Use github.com/dogmatiq/enginekit/message instead.
Index ¶
- func Map[T any](m dogma.Message, command func(dogma.Command) T, event func(dogma.Event) T, ...) (result T)
- func MapKind[T any](k Kind, command, event, timeout T) (result T)
- func Switch(m dogma.Message, command func(dogma.Command), event func(dogma.Event), ...)
- func SwitchKind(k Kind, command func(), event func(), timeout func())
- func TryMap[T any](m dogma.Message, command func(dogma.Command) (T, error), ...) (result T, err error)
- type Kind
- type Name
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶ added in v0.15.0
func Map[T any]( m dogma.Message, command func(dogma.Command) T, event func(dogma.Event) T, timeout func(dogma.Timeout) T, ) (result T)
Map invokes one of the provided functions based on the Kind of m, and returns the result.
It provides a compile-time guarantee that all kinds are handled, even if new Kind values are added in the future.
It panics with a meaningful message if the function associated with m's kind is nil.
It panics if m does not implement dogma.Command, dogma.Event or dogma.Timeout.
func MapKind ¶ added in v0.15.0
MapKind maps k to a value of type T.
It provides a compile-time guarantee that all possible values are handled, even if new Kind values are added in the future.
It panics if k is not a valid Kind.
func Switch ¶ added in v0.15.0
func Switch( m dogma.Message, command func(dogma.Command), event func(dogma.Event), timeout func(dogma.Timeout), )
Switch invokes one of the provided functions based on the Kind of m.
It provides a compile-time guarantee that all kinds are handled, even if new Kind values are added in the future.
It panics with a meaningful message if the function associated with m's kind is nil.
It panics if m does not implement dogma.Command, dogma.Event or dogma.Timeout.
func SwitchKind ¶ added in v0.15.0
func SwitchKind( k Kind, command func(), event func(), timeout func(), )
SwitchKind invokes one of the provided functions based on k.
It provides a compile-time guarantee that all possible values are handled, even if new Kind values are added in the future.
It panics with a meaningful message if the function associated with k.
It panics if k is not a valid Kind.
func TryMap ¶ added in v0.15.0
func TryMap[T any]( m dogma.Message, command func(dogma.Command) (T, error), event func(dogma.Event) (T, error), timeout func(dogma.Timeout) (T, error), ) (result T, err error)
TryMap invokes one of the provided functions based on the Kind of m, and returns the result and error.
It provides a compile-time guarantee that all kinds are handled, even if new Kind values are added in the future.
It panics with a meaningful message if the function associated with m's kind is nil.
It panics if m does not implement dogma.Command, dogma.Event or dogma.Timeout.
Types ¶
type Kind ¶ added in v0.15.0
type Kind int
Kind is an enumeration of the different kinds of messages.
It is similar to a [Role], however it is not tied to a specific application.
func KindFor ¶ added in v0.15.0
KindFor returns the Kind of the message with type T.
It panics if T does not implement dogma.Command, dogma.Event or dogma.Timeout.
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
Name is the fully-qualified name of a message type.
func NameFromStaticType ¶ added in v0.15.0
NameFromStaticType returns the fully-qualified type name of t.
func (Name) MarshalBinary ¶
MarshalBinary returns a binary representation of the name.
func (Name) MarshalText ¶
MarshalText returns a UTF-8 representation of the name.
func (*Name) UnmarshalBinary ¶
UnmarshalBinary unmarshals a type from its binary representation.
func (*Name) UnmarshalText ¶
UnmarshalText unmarshals a name from its UTF-8 representation.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents the type of a Dogma message.
func TypeFromReflect ¶ added in v0.4.1
TypeFromReflect returns the message type of the given reflect type.
func (Type) Kind ¶ added in v0.15.0
Kind returns the kind of the message represented by t.
It panics of t does not implement dogma.Command, dogma.Event or dogma.Timeout.
func (Type) Name ¶
Name returns the fully-qualified name for the Go type.
It panics if t.IsZero() returns true.
func (Type) ReflectType ¶
ReflectType returns the reflect.Type of the message.
It panics if t.IsZero() returns true.