config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: MIT Imports: 7 Imported by: 4

Documentation

Overview

Package config builds and validates Dogma application configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

	// MessageTypes is the set of command message types that are routed to this
	// handler, as specified by its Configure() method.
	MessageTypes message.TypeSet
}

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) CommandTypes

func (c *AggregateConfig) CommandTypes() message.TypeSet

CommandTypes returns the types of command messages that are routed to the handler.

func (*AggregateConfig) EventTypes

func (c *AggregateConfig) EventTypes() message.TypeSet

EventTypes returns the types of event messages that are routed to 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.

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

	// Routes is map of message type to the names of the handlers that receive
	// messages of that type.
	Routes map[message.Type][]string

	// CommandRoutes is map of command message type to the names of the handler
	// that receives that command type.
	CommandRoutes map[message.Type]string

	// EventRoutes is map of event message type to the names of the handlers that
	// receive events of that type.
	EventRoutes 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.

func (Error) Error

func (e Error) Error() string

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

	// CommandTypes returns the types of command messages that are routed to the handler.
	CommandTypes() message.TypeSet

	// EventTypes returns the types of event messages that are routed to the handler.
	EventTypes() message.TypeSet
}

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

	// MessageTypes is the set of command message types that are routed to this
	// handler, as specified by its Configure() method.
	MessageTypes message.TypeSet
}

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) CommandTypes

func (c *IntegrationConfig) CommandTypes() message.TypeSet

CommandTypes returns the types of command messages that are routed to the handler.

func (*IntegrationConfig) EventTypes

func (c *IntegrationConfig) EventTypes() message.TypeSet

EventTypes returns the types of event messages that are routed to 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.

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

	// MessageTypes is the set of event message types that are routed to this
	// handler, as specified by its Configure() method.
	MessageTypes message.TypeSet
}

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) CommandTypes

func (c *ProcessConfig) CommandTypes() message.TypeSet

CommandTypes returns the types of command messages that are routed to the handler.

func (*ProcessConfig) EventTypes

func (c *ProcessConfig) EventTypes() message.TypeSet

EventTypes returns the types of event messages that are routed to 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) Name

func (c *ProcessConfig) Name() string

Name returns the process name.

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

	// MessageTypes is the set of event message types that are routed to this
	// handler, as specified by its Configure() method.
	MessageTypes message.TypeSet
}

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) CommandTypes

func (c *ProjectionConfig) CommandTypes() message.TypeSet

CommandTypes returns the types of command messages that are routed to the handler.

func (*ProjectionConfig) EventTypes

func (c *ProjectionConfig) EventTypes() message.TypeSet

EventTypes returns the types of event messages that are routed to 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.

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.

Jump to

Keyboard shortcuts

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