Documentation
¶
Overview ¶
Package config builds and validates Dogma application configurations.
Index ¶
- func IsValidName(n string) bool
- type AggregateConfig
- func (c *AggregateConfig) Accept(ctx context.Context, v Visitor) error
- func (c *AggregateConfig) ConsumedMessageTypes() map[message.Type]message.Role
- func (c *AggregateConfig) HandlerReflectType() reflect.Type
- func (c *AggregateConfig) HandlerType() handler.Type
- func (c *AggregateConfig) Name() string
- func (c *AggregateConfig) ProducedMessageTypes() map[message.Type]message.Role
- type ApplicationConfig
- type Config
- type Error
- type FuncVisitor
- func (v *FuncVisitor) VisitAggregateConfig(ctx context.Context, cfg *AggregateConfig) error
- func (v *FuncVisitor) VisitApplicationConfig(ctx context.Context, cfg *ApplicationConfig) error
- func (v *FuncVisitor) VisitIntegrationConfig(ctx context.Context, cfg *IntegrationConfig) error
- func (v *FuncVisitor) VisitProcessConfig(ctx context.Context, cfg *ProcessConfig) error
- func (v *FuncVisitor) VisitProjectionConfig(ctx context.Context, cfg *ProjectionConfig) error
- type HandlerConfig
- type IntegrationConfig
- func (c *IntegrationConfig) Accept(ctx context.Context, v Visitor) error
- func (c *IntegrationConfig) ConsumedMessageTypes() map[message.Type]message.Role
- func (c *IntegrationConfig) HandlerReflectType() reflect.Type
- func (c *IntegrationConfig) HandlerType() handler.Type
- func (c *IntegrationConfig) Name() string
- func (c *IntegrationConfig) ProducedMessageTypes() map[message.Type]message.Role
- type ProcessConfig
- func (c *ProcessConfig) Accept(ctx context.Context, v Visitor) error
- func (c *ProcessConfig) ConsumedMessageTypes() map[message.Type]message.Role
- func (c *ProcessConfig) HandlerReflectType() reflect.Type
- func (c *ProcessConfig) HandlerType() handler.Type
- func (c *ProcessConfig) Name() string
- func (c *ProcessConfig) ProducedMessageTypes() map[message.Type]message.Role
- type ProjectionConfig
- func (c *ProjectionConfig) Accept(ctx context.Context, v Visitor) error
- func (c *ProjectionConfig) ConsumedMessageTypes() map[message.Type]message.Role
- func (c *ProjectionConfig) HandlerReflectType() reflect.Type
- func (c *ProjectionConfig) HandlerType() handler.Type
- func (c *ProjectionConfig) Name() string
- func (c *ProjectionConfig) ProducedMessageTypes() map[message.Type]message.Role
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidName ¶ added in v0.2.0
IsValidName returns true if n is a valid application or handler name.
A valid name is a non-empty string consisting of Unicode printable characters, except whitespace.
Types ¶
type AggregateConfig ¶
type AggregateConfig struct {
// Handler is the handler that the configuration applies to.
Handler dogma.AggregateMessageHandler
// HandlerName is the handler's name, as specified by its Configure() method.
HandlerName string
// contains filtered or unexported fields
}
AggregateConfig represents the configuration of an aggregate message handler.
func NewAggregateConfig ¶
func NewAggregateConfig(h dogma.AggregateMessageHandler) (*AggregateConfig, error)
NewAggregateConfig returns an AggregateConfig for the given handler.
func (*AggregateConfig) Accept ¶
func (c *AggregateConfig) Accept(ctx context.Context, v Visitor) error
Accept calls v.VisitAggregateConfig(ctx, c).
func (*AggregateConfig) ConsumedMessageTypes ¶ added in v0.2.0
func (c *AggregateConfig) ConsumedMessageTypes() map[message.Type]message.Role
ConsumedMessageTypes returns the message types consumed by the handler.
func (*AggregateConfig) HandlerReflectType ¶
func (c *AggregateConfig) HandlerReflectType() reflect.Type
HandlerReflectType returns the reflect.Type of the handler.
func (*AggregateConfig) HandlerType ¶
func (c *AggregateConfig) HandlerType() handler.Type
HandlerType returns handler.AggregateType.
func (*AggregateConfig) Name ¶
func (c *AggregateConfig) Name() string
Name returns the aggregate name.
func (*AggregateConfig) ProducedMessageTypes ¶ added in v0.2.0
func (c *AggregateConfig) ProducedMessageTypes() map[message.Type]message.Role
ProducedMessageTypes returns the message types produced by the handler.
type ApplicationConfig ¶
type ApplicationConfig struct {
// Application is the application that the configuration applies to.
Application dogma.Application
// ApplicationName is the application's name, as specified in the dogma.App struct.
ApplicationName string
// Handlers is a map of handler name to their respective configuration.
Handlers map[string]HandlerConfig
// Roles is a map of message type to the role it performs within the
// application. The map does not include timeout message types.
Roles map[message.Type]message.Role
// Consumers is a map of message type to the names of the handlers that
// consume messages of that type.
Consumers map[message.Type][]string
// Producers is a map of message type to the name of the handlers that
// produce messages of that type.
Producers map[message.Type][]string
}
ApplicationConfig represents the configuration of an entire Dogma application.
func NewApplicationConfig ¶
func NewApplicationConfig(app dogma.Application) (*ApplicationConfig, error)
NewApplicationConfig returns a new application config for the given application.
func (*ApplicationConfig) Accept ¶
func (c *ApplicationConfig) Accept(ctx context.Context, v Visitor) error
Accept calls v.VisitApplicationConfig(ctx, c).
func (*ApplicationConfig) Name ¶
func (c *ApplicationConfig) Name() string
Name returns the application name.
type Config ¶
type Config interface {
// Name returns the name of the configured item.
// For example, the application or handler name.
Name() string
// Accept calls the appropriate method on v for this configuration type.
Accept(ctx context.Context, v Visitor) error
}
Config is an interface for all configuration values.
type Error ¶
type Error string
Error is an error representing a fault in an application's configuration.
type FuncVisitor ¶
type FuncVisitor struct {
// ApplicationConfig, if non-nil, is called by VisitApplicationConfig().
ApplicationConfig func(context.Context, *ApplicationConfig) error
// AggregateConfig, if non-nil, is called by VisitAggregateConfig().
AggregateConfig func(context.Context, *AggregateConfig) error
// ProcessConfig, if non-nil, is called by VisitProcessConfig().
ProcessConfig func(context.Context, *ProcessConfig) error
// IntegrationConfig, if non-nil, is called by VisitIntegrationConfig().
IntegrationConfig func(context.Context, *IntegrationConfig) error
// ProjectionConfig, if non-nil, is called by VisitProjectionConfig().
ProjectionConfig func(context.Context, *ProjectionConfig) error
}
FuncVisitor is an implementation of Visitor that dispatches to regular functions.
func (*FuncVisitor) VisitAggregateConfig ¶
func (v *FuncVisitor) VisitAggregateConfig(ctx context.Context, cfg *AggregateConfig) error
VisitAggregateConfig calls v.AggregateConfig if it is non-nil.
func (*FuncVisitor) VisitApplicationConfig ¶
func (v *FuncVisitor) VisitApplicationConfig(ctx context.Context, cfg *ApplicationConfig) error
VisitApplicationConfig calls v.ApplicationConfig if it is non-nil.
func (*FuncVisitor) VisitIntegrationConfig ¶
func (v *FuncVisitor) VisitIntegrationConfig(ctx context.Context, cfg *IntegrationConfig) error
VisitIntegrationConfig calls v.IntegrationConfig if it is non-nil.
func (*FuncVisitor) VisitProcessConfig ¶
func (v *FuncVisitor) VisitProcessConfig(ctx context.Context, cfg *ProcessConfig) error
VisitProcessConfig calls v.ProcessConfig if it is non-nil.
func (*FuncVisitor) VisitProjectionConfig ¶
func (v *FuncVisitor) VisitProjectionConfig(ctx context.Context, cfg *ProjectionConfig) error
VisitProjectionConfig calls v.ProjectionConfig if it is non-nil.
type HandlerConfig ¶
type HandlerConfig interface {
Config
// HandleType returns the type of handler.
HandlerType() handler.Type
// HandlerReflectType returns the reflect.Type of the handler.
HandlerReflectType() reflect.Type
// ConsumedMessageTypes returns the message types consumed by the handler.
ConsumedMessageTypes() map[message.Type]message.Role
// ProducedMessageTypes returns the message types produced by the handler.
ProducedMessageTypes() map[message.Type]message.Role
}
HandlerConfig is an interface for configuration values that refer to a specific message handler.
type IntegrationConfig ¶
type IntegrationConfig struct {
// Handler is the handler that the configuration applies to.
Handler dogma.IntegrationMessageHandler
// HandlerName is the handler's name, as specified by its Configure() method.
HandlerName string
// contains filtered or unexported fields
}
IntegrationConfig represents the configuration of an integration message handler.
func NewIntegrationConfig ¶
func NewIntegrationConfig(h dogma.IntegrationMessageHandler) (*IntegrationConfig, error)
NewIntegrationConfig returns an IntegrationConfig for the given handler.
func (*IntegrationConfig) Accept ¶
func (c *IntegrationConfig) Accept(ctx context.Context, v Visitor) error
Accept calls v.VisitIntegrationConfig(ctx, c).
func (*IntegrationConfig) ConsumedMessageTypes ¶ added in v0.2.0
func (c *IntegrationConfig) ConsumedMessageTypes() map[message.Type]message.Role
ConsumedMessageTypes returns the message types consumed by the handler.
func (*IntegrationConfig) HandlerReflectType ¶
func (c *IntegrationConfig) HandlerReflectType() reflect.Type
HandlerReflectType returns the reflect.Type of the handler.
func (*IntegrationConfig) HandlerType ¶
func (c *IntegrationConfig) HandlerType() handler.Type
HandlerType returns handler.IntegrationType.
func (*IntegrationConfig) Name ¶
func (c *IntegrationConfig) Name() string
Name returns the integration name.
func (*IntegrationConfig) ProducedMessageTypes ¶ added in v0.2.0
func (c *IntegrationConfig) ProducedMessageTypes() map[message.Type]message.Role
ProducedMessageTypes returns the message types produced by the handler.
type ProcessConfig ¶
type ProcessConfig struct {
// Handler is the handler that the configuration applies to.
Handler dogma.ProcessMessageHandler
// HandlerName is the handler's name, as specified by its Configure() method.
HandlerName string
// contains filtered or unexported fields
}
ProcessConfig represents the configuration of an process message handler.
func NewProcessConfig ¶
func NewProcessConfig(h dogma.ProcessMessageHandler) (*ProcessConfig, error)
NewProcessConfig returns an ProcessConfig for the given handler.
func (*ProcessConfig) Accept ¶
func (c *ProcessConfig) Accept(ctx context.Context, v Visitor) error
Accept calls v.VisitProcessConfig(ctx, c).
func (*ProcessConfig) ConsumedMessageTypes ¶ added in v0.2.0
func (c *ProcessConfig) ConsumedMessageTypes() map[message.Type]message.Role
ConsumedMessageTypes returns the message types consumed by the handler.
func (*ProcessConfig) HandlerReflectType ¶
func (c *ProcessConfig) HandlerReflectType() reflect.Type
HandlerReflectType returns the reflect.Type of the handler.
func (*ProcessConfig) HandlerType ¶
func (c *ProcessConfig) HandlerType() handler.Type
HandlerType returns handler.ProcessType.
func (*ProcessConfig) ProducedMessageTypes ¶ added in v0.2.0
func (c *ProcessConfig) ProducedMessageTypes() map[message.Type]message.Role
ProducedMessageTypes returns the message types produced by the handler.
type ProjectionConfig ¶
type ProjectionConfig struct {
// Handler is the handler that the configuration applies to.
Handler dogma.ProjectionMessageHandler
// HandlerName is the handler's name, as specified by its Configure() method.
HandlerName string
// contains filtered or unexported fields
}
ProjectionConfig represents the configuration of an aggregate message handler.
func NewProjectionConfig ¶
func NewProjectionConfig(h dogma.ProjectionMessageHandler) (*ProjectionConfig, error)
NewProjectionConfig returns an ProjectionConfig for the given handler.
func (*ProjectionConfig) Accept ¶
func (c *ProjectionConfig) Accept(ctx context.Context, v Visitor) error
Accept calls v.VisitProjectionConfig(ctx, c).
func (*ProjectionConfig) ConsumedMessageTypes ¶ added in v0.2.0
func (c *ProjectionConfig) ConsumedMessageTypes() map[message.Type]message.Role
ConsumedMessageTypes returns the message types consumed by the handler.
func (*ProjectionConfig) HandlerReflectType ¶
func (c *ProjectionConfig) HandlerReflectType() reflect.Type
HandlerReflectType returns the reflect.Type of the handler.
func (*ProjectionConfig) HandlerType ¶
func (c *ProjectionConfig) HandlerType() handler.Type
HandlerType returns handler.ProjectionType.
func (*ProjectionConfig) Name ¶
func (c *ProjectionConfig) Name() string
Name returns the projection name.
func (*ProjectionConfig) ProducedMessageTypes ¶ added in v0.2.0
func (c *ProjectionConfig) ProducedMessageTypes() map[message.Type]message.Role
ProducedMessageTypes returns the message types produced by the handler.
type Visitor ¶
type Visitor interface {
// VisitApplicationConfig is called by ApplicationConfig.Accept().
VisitApplicationConfig(context.Context, *ApplicationConfig) error
// VisitAggregateConfig is called by AggregateConfig.Accept().
VisitAggregateConfig(context.Context, *AggregateConfig) error
// VisitProcessConfig is called by ProcessConfig.Accept().
VisitProcessConfig(context.Context, *ProcessConfig) error
// VisitIntegrationConfig is called by IntegrationConfig.Accept().
VisitIntegrationConfig(context.Context, *IntegrationConfig) error
// VisitProjectionConfig is called by ProjectionConfig.Accept().
VisitProjectionConfig(context.Context, *ProjectionConfig) error
}
Visitor is an interface for walking application configurations.