Documentation ¶
Index ¶
- func GetTypeName(source interface{}) (reflect.Type, string)
- type AggregateHandler
- type BaseAggregate
- type BaseCommand
- type Command
- type CommandBus
- type CommandHandle
- type CommandHandlerRegister
- type CommandRegister
- type Event
- type EventBus
- type EventStore
- type EventType
- type EventTypeRegister
- type Register
- type Repository
- func (r *Repository) Load(aggregate AggregateHandler, ID string) error
- func (r *Repository) PublishEvents(aggregate AggregateHandler, bucket, subset string) error
- func (r *Repository) SafeSave(aggregate AggregateHandler, version int) error
- func (r *Repository) Save(aggregate AggregateHandler, version int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTypeName ¶
GetTypeName of given struct
Types ¶
type AggregateHandler ¶
type AggregateHandler interface { // LoadsFromHistory(events []Event) ApplyChange(event Event) ApplyChangeHelper(aggregate AggregateHandler, event Event, commit bool) HandleCommand(Command) error Uncommited() []Event ClearUncommited() IncrementVersion() GetID() string }
AggregateHandler defines the methods to process commands
type BaseAggregate ¶
BaseAggregate contains the basic info that all aggregates should have
func (*BaseAggregate) ApplyChangeHelper ¶
func (b *BaseAggregate) ApplyChangeHelper(aggregate AggregateHandler, event Event, commit bool)
ApplyChangeHelper increments the version of an aggregate and apply the change itself
func (*BaseAggregate) ClearUncommited ¶
func (b *BaseAggregate) ClearUncommited()
ClearUncommited the events
func (*BaseAggregate) IncrementVersion ¶
func (b *BaseAggregate) IncrementVersion()
IncrementVersion ads 1 to the current version
func (*BaseAggregate) Uncommited ¶
func (b *BaseAggregate) Uncommited() []Event
Uncommited return the events to be saved
type BaseCommand ¶
BaseCommand contains the basic info that all commands should have
func (BaseCommand) GetAggregateID ¶
func (b BaseCommand) GetAggregateID() string
GetAggregateID returns the command aggregate ID
func (BaseCommand) GetAggregateType ¶
func (b BaseCommand) GetAggregateType() string
GetAggregateType returns the command aggregate type
func (BaseCommand) IsValid ¶
func (b BaseCommand) IsValid() bool
IsValid checks validates the command
type Command ¶
type Command interface { GetType() string GetAggregateID() string GetAggregateType() string IsValid() bool GetVersion() int }
Command contains the methods to retreive basic info about it
type CommandBus ¶
type CommandBus interface {
HandleCommand(command Command)
}
CommandBus serve as the bridge between commands and command handler it should manage the queues
type CommandHandle ¶
CommandHandle defines the contract to handle commands
type CommandHandlerRegister ¶
type CommandHandlerRegister interface { Add(command interface{}, handler CommandHandle) Get(command interface{}) (CommandHandle, error) }
CommandHandlerRegister stores the handlers for commands
type CommandRegister ¶
CommandRegister contains a registry of command-handler style
func NewCommandRegister ¶
func NewCommandRegister() *CommandRegister
NewCommandRegister creates a new CommandHandler
func (*CommandRegister) Add ¶
func (c *CommandRegister) Add(command interface{}, handler CommandHandle)
Add a new command with its handler
func (*CommandRegister) Get ¶
func (c *CommandRegister) Get(command interface{}) (CommandHandle, error)
Get the handler for a command
type Event ¶
type Event struct { ID string `json:"id"` AggregateID string `json:"aggregate_id"` AggregateType string `json:"aggregate_type"` Version int `json:"version"` Type string `json:"type"` Data interface{} `json:"data"` }
Event stores the data for every event
type EventStore ¶
type EventStore interface { Save(events []Event, version int) error SafeSave(events []Event, version int) error Load(aggregateID string) ([]Event, error) }
EventStore saves the events from an aggregate
type EventType ¶
EventType implements the EventyTypeRegister interface
type EventTypeRegister ¶
EventTypeRegister defines the register for all the events that are Data field child of event struct
func NewEventRegister ¶
func NewEventRegister() EventTypeRegister
NewEventRegister gets a EventyTypeRegister interface
type Register ¶
type Register interface { Set(source interface{}) Get(name string) (interface{}, error) Count() int }
Register defines generic methods to create a registry
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is responsible to generate an Aggregate save events and publish it
func NewRepository ¶
func NewRepository(store EventStore, bus EventBus) *Repository
NewRepository creates a repository wieh a eventstore and eventbus access
func (*Repository) Load ¶
func (r *Repository) Load(aggregate AggregateHandler, ID string) error
Load restore the last state of an aggregate
func (*Repository) PublishEvents ¶
func (r *Repository) PublishEvents(aggregate AggregateHandler, bucket, subset string) error
PublishEvents to an eventBus
func (*Repository) SafeSave ¶
func (r *Repository) SafeSave(aggregate AggregateHandler, version int) error
SafeSave the events without check the version
func (*Repository) Save ¶
func (r *Repository) Save(aggregate AggregateHandler, version int) error
Save the events and publish it to eventbus
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
commandbus
|
|
commandhandler
|
|
Package config contains helpers used to generate the initial config using a functional style instead the common service attach
|
Package config contains helpers used to generate the initial config using a functional style instead the common service attach |
eventstore
|
|
examples
|
|