Documentation
¶
Index ¶
- func Decode(object interface{}, data []byte) error
- func Encode(object interface{}) ([]byte, error)
- func NewIdentity(objectType string) string
- type DomainObject
- type DomainObjectMemento
- type Event
- type EventPublisher
- type EventReceiver
- type EventStream
- type InMemoryRepository
- type MongoRepository
- type Repository
- type Stream
- func (s *Stream) AddEvent(object DomainObject, eventName string, payload msgp.Marshaler) error
- func (s *Stream) Clear()
- func (s *Stream) ContainsEventWithId(eventId string) bool
- func (s *Stream) Events() []Event
- func (s *Stream) LastVersion() int
- func (s *Stream) LoadEvent(object DomainObject, event Event) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewIdentity ¶
Types ¶
type DomainObject ¶
type DomainObject interface {
EventStream
ObjectID() string
Apply(eventName string, eventPayload []byte) error
}
DomainObject is an interface representing a domain object necessary methods
type DomainObjectMemento ¶ added in v1.3.0
type DomainObjectMemento interface {
DumpMemento() (msgp.Marshaler, error)
ApplyMemento(payload []byte) error
}
DomainObjectMemento is an interface representing a domain object capable of exposing a memento
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event represents a domain Event
func ReloadEvent ¶ added in v1.2.1
type EventPublisher ¶
type EventPublisher struct {
Wait bool
// contains filtered or unexported fields
}
func NewEventPublisher ¶
func NewEventPublisher() EventPublisher
func (*EventPublisher) Publish ¶
func (p *EventPublisher) Publish(events []Event)
func (*EventPublisher) Register ¶
func (p *EventPublisher) Register(receiver EventReceiver)
type EventReceiver ¶
type EventReceiver interface {
OnEvent(event Event)
}
type EventStream ¶
type EventStream interface {
AddEvent(object DomainObject, eventName string, payload msgp.Marshaler) error
LoadEvent(object DomainObject, event Event) error
Events() []Event
LastVersion() int
ContainsEventWithId(eventID string) bool
Clear()
// contains filtered or unexported methods
}
EventStream is an interface representing a stream of events
type InMemoryRepository ¶
type InMemoryRepository struct {
// contains filtered or unexported fields
}
func NewInMemoryRepository ¶
func NewInMemoryRepository(publisher *EventPublisher) InMemoryRepository
func (*InMemoryRepository) EventsSince ¶ added in v1.2.0
func (*InMemoryRepository) Exists ¶
func (r *InMemoryRepository) Exists(objectId string) (bool, error)
func (*InMemoryRepository) Load ¶
func (r *InMemoryRepository) Load(objectID string, object DomainObject) error
func (*InMemoryRepository) Save ¶
func (r *InMemoryRepository) Save(object DomainObject) error
type MongoRepository ¶
type MongoRepository struct {
// contains filtered or unexported fields
}
func NewMongoRepository ¶
func NewMongoRepository(database *mongo.Database, publisher *EventPublisher) MongoRepository
func (*MongoRepository) EventsSince ¶ added in v1.2.0
func (*MongoRepository) Load ¶
func (r *MongoRepository) Load(objectID string, object DomainObject) error
func (*MongoRepository) Save ¶
func (r *MongoRepository) Save(object DomainObject) error
type Repository ¶
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is an implementation of an EventStream
func (*Stream) ContainsEventWithId ¶
ContainsEventWithId checks if an event is known in the stream
func (*Stream) LastVersion ¶
LastVersion returns the last known version
Source Files
¶
Click to show internal directories.
Click to hide internal directories.