Documentation
¶
Overview ¶
Package configkit is a set of utilities for working with Dogma application configurations as well as that of their constituent message handlers and the messages that they operate upon.
Index ¶
- Variables
- func Panicf(f string, v ...interface{})
- func Recover(err *error)
- type Aggregate
- type Application
- type Entity
- type EntityMessageNames
- type EntityMessageTypes
- type Error
- type Handler
- type HandlerSet
- func (s HandlerSet) AcceptVisitor(ctx context.Context, v Visitor) error
- func (s HandlerSet) Add(h Handler) bool
- func (s HandlerSet) ByIdentity(i Identity) (Handler, bool)
- func (s HandlerSet) ByKey(k string) (Handler, bool)
- func (s HandlerSet) ByName(n string) (Handler, bool)
- func (s HandlerSet) ByType(t HandlerType) HandlerSet
- func (s HandlerSet) ConsumersOf(n message.Name) HandlerSet
- func (s HandlerSet) Filter(fn func(Handler) bool) HandlerSet
- func (s HandlerSet) Find(fn func(Handler) bool) (Handler, bool)
- func (s HandlerSet) Has(h Handler) bool
- func (s HandlerSet) ProducersOf(n message.Name) HandlerSet
- type HandlerType
- func (t HandlerType) Consumes() []message.Role
- func (t HandlerType) Is(types ...HandlerType) bool
- func (t HandlerType) IsConsumerOf(r message.Role) bool
- func (t HandlerType) IsProducerOf(r message.Role) bool
- func (t HandlerType) MarshalBinary() ([]byte, error)
- func (t HandlerType) MarshalText() ([]byte, error)
- func (t HandlerType) MustBe(types ...HandlerType)
- func (t HandlerType) MustNotBe(types ...HandlerType)
- func (t HandlerType) MustValidate()
- func (t HandlerType) Produces() []message.Role
- func (t HandlerType) ShortString() string
- func (t HandlerType) String() string
- func (t *HandlerType) UnmarshalBinary(data []byte) error
- func (t *HandlerType) UnmarshalText(text []byte) error
- func (t HandlerType) Validate() error
- type Identity
- type Integration
- type Process
- type Projection
- type RichAggregate
- type RichApplication
- type RichEntity
- type RichHandler
- type RichHandlerSet
- func (s RichHandlerSet) AcceptRichVisitor(ctx context.Context, v RichVisitor) error
- func (s RichHandlerSet) Add(h RichHandler) bool
- func (s RichHandlerSet) ByIdentity(i Identity) (RichHandler, bool)
- func (s RichHandlerSet) ByKey(k string) (RichHandler, bool)
- func (s RichHandlerSet) ByName(n string) (RichHandler, bool)
- func (s RichHandlerSet) ByType(t HandlerType) RichHandlerSet
- func (s RichHandlerSet) ConsumersOf(t message.Type) RichHandlerSet
- func (s RichHandlerSet) Filter(fn func(RichHandler) bool) RichHandlerSet
- func (s RichHandlerSet) Find(fn func(RichHandler) bool) (RichHandler, bool)
- func (s RichHandlerSet) Has(h RichHandler) bool
- func (s RichHandlerSet) ProducersOf(t message.Type) RichHandlerSet
- type RichIntegration
- type RichProcess
- type RichProjection
- type RichVisitor
- type Visitor
Constants ¶
This section is empty.
Variables ¶
var HandlerTypes = []HandlerType{ AggregateHandlerType, ProcessHandlerType, IntegrationHandlerType, ProjectionHandlerType, }
HandlerTypes is a slice of the valid handler types.
Functions ¶
Types ¶
type Aggregate ¶
type Aggregate interface {
Handler
}
Aggregate is an interface that represents the configuration of a Dogma aggregate message handler.
type Application ¶
type Application interface {
Entity
// Handlers returns the handlers within this application.
Handlers() HandlerSet
// ForeignMessageNames returns the message names that this application
// uses that must be communicated beyond the scope of the application.
//
// This includes:
// - commands that are produced by this application, but consumed elsewhere
// - commands that are consumed by this application, but produced elsewhere
// - events that are consumed by this application, but produced elsewhere
ForeignMessageNames() EntityMessageNames
}
Application is an interface that represents the configuration of a Dogma application.
type Entity ¶
type Entity interface {
// Identity returns the identity of the entity.
Identity() Identity
// TypeName returns the fully-qualified type name of the entity.
TypeName() string
// MessageNames returns information about the messages used by the entity.
MessageNames() EntityMessageNames
// AcceptVisitor calls the appropriate method on v for this entity type.
AcceptVisitor(ctx context.Context, v Visitor) error
}
Entity is an interface that represents the configuration of a Dogma "entity" such as an application or handler.
Each implementation of this interface represents the configuration described by a call to the entity's Configure() method.
type EntityMessageNames ¶
type EntityMessageNames struct {
// Roles is a map of message name to its role within the entity.
Roles message.NameRoles
// Produced is a set of message names produced by the entity.
Produced message.NameRoles
// Consumed is a set of message names consumed by the entity.
Consumed message.NameRoles
}
EntityMessageNames describes how messages are used within a Dogma entity where each message is identified by its name.
type EntityMessageTypes ¶
type EntityMessageTypes struct {
// Roles is a map of message type to its role within the entity.
Roles message.TypeRoles
// Produced is a set of message types produced by the entity.
Produced message.TypeRoles
// Consumed is a set of message types consumed by the entity.
Consumed message.TypeRoles
}
EntityMessageTypes describes how messages are used within a Dogma entity where each message is identified by its type.
type Handler ¶
type Handler interface {
Entity
// HandlerType returns the type of handler.
HandlerType() HandlerType
}
Handler is a specialization of the Entity interface for message handlers.
type HandlerSet ¶
HandlerSet is a collection of handlers.
func NewHandlerSet ¶
func NewHandlerSet(handlers ...Handler) HandlerSet
NewHandlerSet returns a HandlerSet containing the given handlers.
It panics if any of the handler identities conflict.
func (HandlerSet) AcceptVisitor ¶ added in v0.1.1
func (s HandlerSet) AcceptVisitor(ctx context.Context, v Visitor) error
AcceptVisitor visits each handler in the set.
It returns the error returned by the first handler to return a non-nil error. It returns nil if all handlers accept the visitor without failure.
The order in which handlers are visited is not guaranteed.
func (HandlerSet) Add ¶
func (s HandlerSet) Add(h Handler) bool
Add adds a handler to the set.
It returns true if the handler was added, or false if the set already contained a handler with the same name or key as h.
func (HandlerSet) ByIdentity ¶
func (s HandlerSet) ByIdentity(i Identity) (Handler, bool)
ByIdentity returns the handler with the given identity.
func (HandlerSet) ByKey ¶
func (s HandlerSet) ByKey(k string) (Handler, bool)
ByKey returns the handler with the given key.
func (HandlerSet) ByName ¶
func (s HandlerSet) ByName(n string) (Handler, bool)
ByName returns the handler with the given name.
func (HandlerSet) ByType ¶
func (s HandlerSet) ByType(t HandlerType) HandlerSet
ByType returns the subset of handlers of the given type.
func (HandlerSet) ConsumersOf ¶
func (s HandlerSet) ConsumersOf(n message.Name) HandlerSet
ConsumersOf returns the subset of handlers that consume messages with the given name.
func (HandlerSet) Filter ¶
func (s HandlerSet) Filter(fn func(Handler) bool) HandlerSet
Filter returns the subset of handlers for which the given predicate function returns true.
func (HandlerSet) Find ¶
func (s HandlerSet) Find(fn func(Handler) bool) (Handler, bool)
Find returns a handler from the set for which the given predicate function returns true.
func (HandlerSet) ProducersOf ¶
func (s HandlerSet) ProducersOf(n message.Name) HandlerSet
ProducersOf returns the subset of handlers that produce messages with the given name.
type HandlerType ¶
type HandlerType string
HandlerType is an enumeration of the types of handlers.
const ( // AggregateHandlerType is the handler type for dogma.AggregateMessageHandler. AggregateHandlerType HandlerType = "aggregate" // ProcessHandlerType is the handler type for dogma.ProcessMessageHandler. ProcessHandlerType HandlerType = "process" // IntegrationHandlerType is the handler type for dogma.IntegrationMessageHandler. IntegrationHandlerType HandlerType = "integration" // ProjectionHandlerType is the handler type for dogma.ProjectionMessageHandler. ProjectionHandlerType HandlerType = "projection" )
func ConsumersOf ¶
func ConsumersOf(r message.Role) []HandlerType
ConsumersOf returns the handler types that can consume messages with the given role.
func ProducersOf ¶
func ProducersOf(r message.Role) []HandlerType
ProducersOf returns the handler types that can produces messages with the given role.
func (HandlerType) Consumes ¶
func (t HandlerType) Consumes() []message.Role
Consumes returns the roles of messages that can be consumed by handlers of this type.
func (HandlerType) Is ¶
func (t HandlerType) Is(types ...HandlerType) bool
Is returns true if t is one of the given types.
func (HandlerType) IsConsumerOf ¶
func (t HandlerType) IsConsumerOf(r message.Role) bool
IsConsumerOf returns true if handlers of type t can consume messages with the given role.
func (HandlerType) IsProducerOf ¶
func (t HandlerType) IsProducerOf(r message.Role) bool
IsProducerOf returns true if handlers of type t can produce messages with the given role.
func (HandlerType) MarshalBinary ¶
func (t HandlerType) MarshalBinary() ([]byte, error)
MarshalBinary returns a binary representation of the handler type.
func (HandlerType) MarshalText ¶
func (t HandlerType) MarshalText() ([]byte, error)
MarshalText returns a UTF-8 representation of the handler type.
func (HandlerType) MustBe ¶
func (t HandlerType) MustBe(types ...HandlerType)
MustBe panics if t is not one of the given types.
func (HandlerType) MustNotBe ¶
func (t HandlerType) MustNotBe(types ...HandlerType)
MustNotBe panics if t is one of the given types.
func (HandlerType) MustValidate ¶
func (t HandlerType) MustValidate()
MustValidate panics if t is not a valid handler type.
func (HandlerType) Produces ¶
func (t HandlerType) Produces() []message.Role
Produces returns the roles of messages that can be produced by handlers of this type.
func (HandlerType) ShortString ¶
func (t HandlerType) ShortString() string
ShortString returns a short (3-character) representation of the handler type.
func (HandlerType) String ¶
func (t HandlerType) String() string
String returns a string representation of the handler type.
func (*HandlerType) UnmarshalBinary ¶
func (t *HandlerType) UnmarshalBinary(data []byte) error
UnmarshalBinary unmarshals a type from its binary representation.
func (*HandlerType) UnmarshalText ¶
func (t *HandlerType) UnmarshalText(text []byte) error
UnmarshalText unmarshals a type from its UTF-8 representation.
func (HandlerType) Validate ¶
func (t HandlerType) Validate() error
Validate returns an error if t is not a valid handler type.
type Identity ¶
type Identity struct {
// Name is the name component of the identity.
//
// For handlers, it is unique within an application at any given version,
// but may be changed over time.
//
// It is allowed, but not recommended to use the same name for an
// application as one of its constituent handlers.
Name string
// Key is the key component of the identity.
//
// It is not only unique within an application, but forever immutable. It is
// not permitted for an application and one of its constituent handlers to
// share the same key.
Key string
}
Identity is the application-defined identity of a Dogma entity.
func MustNewIdentity ¶
MustNewIdentity returns a new identity.
It panics if either of the name or key components is invalid.
func NewIdentity ¶
NewIdentity returns a new identity.
It returns a non-nil error if either of the name or key components is invalid.
func (Identity) ConflictsWith ¶
ConflictsWith returns true if i has the same name or key as ident.
type Integration ¶
type Integration interface {
Handler
}
Integration is an interface that represents the configuration of a Dogma integration message handler.
type Process ¶
type Process interface {
Handler
}
Process is an interface that represents the configuration of a Dogma process message handler.
type Projection ¶
type Projection interface {
Handler
}
Projection is an interface that represents the configuration of a Dogma projection message handler.
type RichAggregate ¶
type RichAggregate interface {
RichHandler
// Handler returns the underlying message handler.
Handler() dogma.AggregateMessageHandler
}
RichAggregate is a specialization of Aggregate that exposes information about the Go types used to implement the underlying Dogma handler.
func FromAggregate ¶
func FromAggregate(h dogma.AggregateMessageHandler) RichAggregate
FromAggregate returns the configuration for an aggregate message handler.
It panics if the handler is configured incorrectly. Use Recover() to convert configuration related panic values to errors.
type RichApplication ¶
type RichApplication interface {
RichEntity
// Handlers returns the handlers within this application.
Handlers() HandlerSet
// RichHandlers returns the handlers within this application.
RichHandlers() RichHandlerSet
// ForeignMessageNames returns the message names that this application
// uses that must be communicated beyond the scope of the application.
//
// This includes:
// - commands that are produced by this application, but consumed elsewhere
// - commands that are consumed by this application, but produced elsewhere
// - events that are consumed by this application, but produced elsewhere
ForeignMessageNames() EntityMessageNames
// ForeignMessageTypes returns the message types that this application
// uses that must be communicated beyond the scope of the application.
//
// This includes:
// - commands that are produced by this application, but consumed elsewhere
// - commands that are consumed by this application, but produced elsewhere
// - events that are consumed by this application, but produced elsewhere
ForeignMessageTypes() EntityMessageTypes
// Application returns the underlying application.
Application() dogma.Application
}
RichApplication is a specialization of Application that exposes information about the Go types used to implement the Dogma application.
func FromApplication ¶
func FromApplication(a dogma.Application) RichApplication
FromApplication returns the configuration for an application.
It panics if the application is configured incorrectly. Use Recover() to convert configuration related panic values to errors.
type RichEntity ¶
type RichEntity interface {
Entity
// ReflectType returns the reflect.Type of the Dogma entity.
ReflectType() reflect.Type
// MessageTypes returns information about the messages used by the entity.
MessageTypes() EntityMessageTypes
// AcceptRichVisitor calls the appropriate method on v for this
// configuration type.
AcceptRichVisitor(ctx context.Context, v RichVisitor) error
}
RichEntity is a specialization of the Entity interface that exposes information about the Go types used to implement the Dogma entity.
type RichHandler ¶
type RichHandler interface {
RichEntity
// HandlerType returns the type of handler.
HandlerType() HandlerType
}
RichHandler is a specialization of the Handler interface that exposes information about the Go types used to implement the Dogma application.
type RichHandlerSet ¶
type RichHandlerSet map[Identity]RichHandler
RichHandlerSet is a collection of rich handlers.
func NewRichHandlerSet ¶
func NewRichHandlerSet(handlers ...RichHandler) RichHandlerSet
NewRichHandlerSet returns a RichHandlerSet containing the given handlers.
It panics if any of the handler identities conflict.
func (RichHandlerSet) AcceptRichVisitor ¶ added in v0.1.1
func (s RichHandlerSet) AcceptRichVisitor(ctx context.Context, v RichVisitor) error
AcceptRichVisitor visits each handler in the set.
It returns the error returned by the first handler to return a non-nil error. It returns nil if all handlers accept the visitor without failure.
The order in which handlers are visited is not guaranteed.
func (RichHandlerSet) Add ¶
func (s RichHandlerSet) Add(h RichHandler) bool
Add adds a handler to the set.
It returns true if the handler was added, or false if the set already contained a handler with the same name or key as h.
func (RichHandlerSet) ByIdentity ¶
func (s RichHandlerSet) ByIdentity(i Identity) (RichHandler, bool)
ByIdentity returns the handler with the given identity.
func (RichHandlerSet) ByKey ¶
func (s RichHandlerSet) ByKey(k string) (RichHandler, bool)
ByKey returns the handler with the given key.
func (RichHandlerSet) ByName ¶
func (s RichHandlerSet) ByName(n string) (RichHandler, bool)
ByName returns the handler with the given name.
func (RichHandlerSet) ByType ¶
func (s RichHandlerSet) ByType(t HandlerType) RichHandlerSet
ByType returns the subset of handlers of the given type.
func (RichHandlerSet) ConsumersOf ¶
func (s RichHandlerSet) ConsumersOf(t message.Type) RichHandlerSet
ConsumersOf returns the subset of handlers that consume messages of the given type.
func (RichHandlerSet) Filter ¶
func (s RichHandlerSet) Filter(fn func(RichHandler) bool) RichHandlerSet
Filter returns the subset of handlers for which the given predicate function returns true.
func (RichHandlerSet) Find ¶
func (s RichHandlerSet) Find(fn func(RichHandler) bool) (RichHandler, bool)
Find returns a handler from the set for which the given predicate function returns true.
func (RichHandlerSet) Has ¶
func (s RichHandlerSet) Has(h RichHandler) bool
Has returns true if s contains h.
func (RichHandlerSet) ProducersOf ¶
func (s RichHandlerSet) ProducersOf(t message.Type) RichHandlerSet
ProducersOf returns the subset of handlers that produce messages of the given type.
type RichIntegration ¶
type RichIntegration interface {
RichHandler
// Handler returns the underlying message handler.
Handler() dogma.IntegrationMessageHandler
}
RichIntegration is a specialization of Integration that exposes information about the Go types used to implement the underlying Dogma handler.
func FromIntegration ¶
func FromIntegration(h dogma.IntegrationMessageHandler) RichIntegration
FromIntegration returns the configuration for an integration message handler.
It panics if the handler is configured incorrectly. Use Recover() to convert configuration related panic values to errors.
type RichProcess ¶
type RichProcess interface {
RichHandler
// Handler returns the underlying message handler.
Handler() dogma.ProcessMessageHandler
}
RichProcess is a specialization of Process that exposes information about the Go types used to implement the underlying Dogma handler.
func FromProcess ¶
func FromProcess(h dogma.ProcessMessageHandler) RichProcess
FromProcess returns the configuration for a process message handler.
It panics if the handler is configured incorrectly. Use Recover() to convert configuration related panic values to errors.
type RichProjection ¶
type RichProjection interface {
RichHandler
// Handler returns the underlying message handler.
Handler() dogma.ProjectionMessageHandler
}
RichProjection is a specialization of Projection that exposes information about the Go types used to implement the underlying Dogma handler.
func FromProjection ¶
func FromProjection(h dogma.ProjectionMessageHandler) RichProjection
FromProjection returns the configuration for a projection message handler.
It panics if the handler is configured incorrectly. Use Recover() to convert configuration related panic values to errors.
type RichVisitor ¶
type RichVisitor interface {
VisitRichApplication(context.Context, RichApplication) error
VisitRichAggregate(context.Context, RichAggregate) error
VisitRichProcess(context.Context, RichProcess) error
VisitRichIntegration(context.Context, RichIntegration) error
VisitRichProjection(context.Context, RichProjection) error
}
RichVisitor is a visitor that visits "rich" configurations.
type Visitor ¶
type Visitor interface {
VisitApplication(context.Context, Application) error
VisitAggregate(context.Context, Aggregate) error
VisitProcess(context.Context, Process) error
VisitIntegration(context.Context, Integration) error
VisitProjection(context.Context, Projection) error
}
Visitor is a visitor that visits configurations.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package message provides utilities for representing information about Dogma messages and their use within an application.
|
Package message provides utilities for representing information about Dogma messages and their use within an application. |