Documentation ¶
Index ¶
- type Option
- type Repository
- func (r *Repository) Apply(ctx context.Context, command es.Command) (int64, error)
- func (r *Repository) Load(ctx context.Context, aggregateID string) (es.Aggregate, error)
- func (r *Repository) New() es.Aggregate
- func (r *Repository) Save(ctx context.Context, events ...es.Event) error
- func (r *Repository) Serializer() es.Serializer
- func (r *Repository) Store() es.Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Repository) error
Option provides functional configuration for a *Repository
func WithEvents ¶
WithEvents binds one or more events to the Serializer. If you choose not to use the default serializer you need to provide the WithSerializer option before this option or the events will be bound to the default serializer instead of the one you later specify.
func WithObservers ¶
WithObservers allows observers to watch the saved events; Observers should invoke very short lived operations as calls will block until the observer is finished
func WithSerializer ¶
func WithSerializer(serializer es.Serializer) Option
WithSerializer specifies the serializer to be used.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides the primary abstraction to saving and loading events
func New ¶
New creates a new Repository using defaults and then applying any operations.
Defaults ¶
A repository is built with the following defaults:
- Memory store
- Gob serializer
func (*Repository) Apply ¶
Apply executes the command specified and returns the current version of the aggregate
func (*Repository) New ¶
func (r *Repository) New() es.Aggregate
New returns a new instance of the aggregate
func (*Repository) Serializer ¶
func (r *Repository) Serializer() es.Serializer
Serializer returns the underlying serializer