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
- func (r *MongoRepository) EventsSince(timestamp time.Time, limit int) ([]Event, error)
- func (r *MongoRepository) Exists(objectId string) (bool, error)
- func (r *MongoRepository) Load(objectID string, object DomainObject) error
- func (r *MongoRepository) ObjectEventsSinceVersion(objectID string, version int) ([]Event, error)
- func (r *MongoRepository) Save(object DomainObject) error
- type RemoteEventListener
- type RemoteEventPublisher
- type Repository
- type Stream
- func (s *Stream) AddEvent(object DomainObject, eventName string, payload msgp.Marshaler) error
- func (s *Stream) Clear()
- func (s *Stream) CollectUnsavedEvents() []Event
- 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
- func (s *Stream) SetStreamVersion(version int)
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
SetVersion(version int)
}
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 Deserialize ¶ added in v1.3.5
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) OnEvent ¶ added in v1.3.5
func (p *EventPublisher) OnEvent(event Event)
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)
}
func NewRemoteEventPublisher ¶ added in v1.3.5
func NewRemoteEventPublisher(queue services.QueueService, errChan chan<- error) EventReceiver
type EventStream ¶
type EventStream interface {
AddEvent(object DomainObject, eventName string, payload msgp.Marshaler) error
LoadEvent(object DomainObject, event Event) error
Events() []Event
CollectUnsavedEvents() []Event
LastVersion() int
SetStreamVersion(version int)
ContainsEventWithId(eventID string) bool
Clear()
}
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) ObjectEventsSinceVersion ¶ added in v1.3.1
func (r *MongoRepository) ObjectEventsSinceVersion(objectID string, version int) ([]Event, error)
func (*MongoRepository) Save ¶
func (r *MongoRepository) Save(object DomainObject) error
type RemoteEventListener ¶ added in v1.3.5
type RemoteEventListener struct {
// contains filtered or unexported fields
}
func NewRemoteEventListener ¶ added in v1.3.5
func NewRemoteEventListener(queue services.QueueService, receiver EventReceiver, errChan chan<- error) RemoteEventListener
func (*RemoteEventListener) Listen ¶ added in v1.3.5
func (r *RemoteEventListener) Listen()
type RemoteEventPublisher ¶ added in v1.3.5
type RemoteEventPublisher struct {
// contains filtered or unexported fields
}
func (*RemoteEventPublisher) OnEvent ¶ added in v1.3.5
func (r *RemoteEventPublisher) OnEvent(event Event)
type Repository ¶
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is an implementation of an EventStream
func (*Stream) CollectUnsavedEvents ¶ added in v1.3.9
func (*Stream) ContainsEventWithId ¶
ContainsEventWithId checks if an event is known in the stream
func (*Stream) LastVersion ¶
LastVersion returns the last known version
func (*Stream) LoadEvent ¶
func (s *Stream) LoadEvent(object DomainObject, event Event) error
LoadEvent load an existing event into the stream
func (*Stream) SetStreamVersion ¶ added in v1.3.1
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.