Documentation ¶
Index ¶
- type Aggregate
- type AggregateLoader
- type AggregateRepository
- type AggregateSaver
- type BaseAggregate
- func (ba *BaseAggregate) AppendChanges(event Event)
- func (*BaseAggregate) Apply(_ Event) error
- func (*BaseAggregate) EventTable() string
- func (ba *BaseAggregate) GetAggregateID() uuid.UUID
- func (ba *BaseAggregate) GetChanges() []Event
- func (ba *BaseAggregate) GetCurrentState() State
- func (ba *BaseAggregate) GetTransitions() []Transition
- func (ba *BaseAggregate) GetVersion() int
- func (ba *BaseAggregate) SetAggregateID(id uuid.UUID)
- func (ba *BaseAggregate) SetVersion(version int)
- func (ba *BaseAggregate) SkipTransition(Event) bool
- type BaseEvent
- func (*BaseEvent) EventType() EventType
- func (be *BaseEvent) GetAggregateID() uuid.UUID
- func (be *BaseEvent) GetCreatedAt() time.Time
- func (be *BaseEvent) GetParentID() uuid.UUID
- func (be *BaseEvent) GetVersion() int
- func (be *BaseEvent) SetAggregateID(id uuid.UUID)
- func (be *BaseEvent) SetCreatedAt(createdAt time.Time)
- func (be *BaseEvent) SetParentID(parentID uuid.UUID)
- func (be *BaseEvent) SetVersion(version int)
- func (be *BaseEvent) Validate() error
- type Event
- type EventNotRegisteredError
- type EventRegistry
- type EventStore
- type EventType
- type InvalidEventError
- type NoTransitionError
- type Projector
- type State
- type StateMachine
- type Transition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregate ¶
type Aggregate interface { // Appply updates aggregate based on event. Apply(event Event) error // Changes returns a list of uncommitted events. GetChanges() []Event // AppendChanges add a event to a uncommitted event list. AppendChanges(event Event) // SetAggregateID assigns identifier to aggregate. SetAggregateID(uuid.UUID) // GetAggregateID returns unique identifier of aggregate. GetAggregateID() uuid.UUID // GetVersion return current version of the aggregate. GetVersion() int // SetVersion sets current version of the aggregate. SetVersion(int) // EventTable return the table name. EventTable() string StateMachine }
type AggregateLoader ¶
type AggregateRepository ¶
type AggregateSaver ¶
type BaseAggregate ¶
type BaseAggregate struct { Version int ID uuid.UUID // contains filtered or unexported fields }
BaseAggregate implements common functionality for Aggregate interface.
It doesn't implement Apply, EventTable.
func (*BaseAggregate) AppendChanges ¶
func (ba *BaseAggregate) AppendChanges(event Event)
func (*BaseAggregate) Apply ¶
func (*BaseAggregate) Apply(_ Event) error
func (*BaseAggregate) EventTable ¶
func (*BaseAggregate) EventTable() string
func (*BaseAggregate) GetAggregateID ¶
func (ba *BaseAggregate) GetAggregateID() uuid.UUID
func (*BaseAggregate) GetChanges ¶
func (ba *BaseAggregate) GetChanges() []Event
func (*BaseAggregate) GetCurrentState ¶
func (ba *BaseAggregate) GetCurrentState() State
func (*BaseAggregate) GetTransitions ¶
func (ba *BaseAggregate) GetTransitions() []Transition
func (*BaseAggregate) GetVersion ¶
func (ba *BaseAggregate) GetVersion() int
func (*BaseAggregate) SetAggregateID ¶
func (ba *BaseAggregate) SetAggregateID(id uuid.UUID)
func (*BaseAggregate) SetVersion ¶
func (ba *BaseAggregate) SetVersion(version int)
func (*BaseAggregate) SkipTransition ¶
func (ba *BaseAggregate) SkipTransition(Event) bool
type BaseEvent ¶
type BaseEvent struct { CreatedAt time.Time Version int ID uuid.UUID AggregateID uuid.UUID ParentID uuid.UUID }
BaseEvent implements common functionality for Event interface.
It doesn't implement EventType method.
func (*BaseEvent) GetAggregateID ¶
func (be *BaseEvent) GetAggregateID() uuid.UUID
func (*BaseEvent) GetCreatedAt ¶
func (*BaseEvent) GetParentID ¶
func (be *BaseEvent) GetParentID() uuid.UUID
func (*BaseEvent) GetVersion ¶
func (*BaseEvent) SetAggregateID ¶
func (be *BaseEvent) SetAggregateID(id uuid.UUID)
func (*BaseEvent) SetCreatedAt ¶
func (*BaseEvent) SetParentID ¶
func (be *BaseEvent) SetParentID(parentID uuid.UUID)
func (*BaseEvent) SetVersion ¶
type Event ¶
type Event interface { // EventType returns the name of event. EventType() EventType // GetAggregateID returns event's aggregate id. GetAggregateID() uuid.UUID // SetAggregateID changes event's aggregate id. SetAggregateID(uuid.UUID) // GetParentID returns event's parent id GetParentID() uuid.UUID // SetParentID changes event's parent id SetParentID(uuid.UUID) // GetVersion returns event's version GetVersion() int // SetVersion changes event's version SetVersion(int) // GetCreatedAt returns event's create time GetCreatedAt() time.Time // SetCreatedAt changes event's create time SetCreatedAt(time.Time) // Validate checks if event is valid Validate() error }
type EventNotRegisteredError ¶
type EventNotRegisteredError struct {
// contains filtered or unexported fields
}
func (*EventNotRegisteredError) Error ¶
func (enre *EventNotRegisteredError) Error() string
type EventRegistry ¶
type EventRegistry struct {
// contains filtered or unexported fields
}
func NewEventRegistry ¶
func NewEventRegistry() *EventRegistry
func NewEventRegistryFromStateMachine ¶
func NewEventRegistryFromStateMachine(stateMachine StateMachine) *EventRegistry
func (*EventRegistry) GetInstance ¶
func (er *EventRegistry) GetInstance(eventType EventType) (Event, error)
func (*EventRegistry) Register ¶
func (er *EventRegistry) Register(event Event)
type EventStore ¶
type InvalidEventError ¶
func (*InvalidEventError) Error ¶
func (e *InvalidEventError) Error() string
func (*InvalidEventError) Unwrap ¶
func (e *InvalidEventError) Unwrap() error
type NoTransitionError ¶
type NoTransitionError struct {
// contains filtered or unexported fields
}
func (*NoTransitionError) Error ¶
func (nte *NoTransitionError) Error() string
type State ¶
type State string
func TransistOnEvent ¶
func TransistOnEvent(stateMachine StateMachine, event Event) (State, error)
TransistOnEvent returns the new state given current state and event.
type StateMachine ¶
type StateMachine interface { // GetStates returns current state of a aggregate. GetCurrentState() State // GetTransitions return all possible state transition for a aggregate GetTransitions() []Transition // SkipTransition returns true if the transition should be skipped. SkipTransition(event Event) bool }
type Transition ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.