Documentation ¶
Index ¶
- type Entity
- type KafkaProvider
- type MemoryRepository
- func (r *MemoryRepository) AddNewEvent(event goeh.Event)
- func (r *MemoryRepository) AddOrModifyEntity(entity Entity)
- func (r *MemoryRepository) GetEntity(id string) (Entity, error)
- func (r *MemoryRepository) GetUncommitedChanges() []goeh.Event
- func (r *MemoryRepository) InitProvider(provider Provider, child Repository) error
- func (r *MemoryRepository) Replay(events []goeh.Event) error
- func (r *MemoryRepository) Save(events []goeh.Event) error
- type Provider
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity interface {
GetId() string
}
Entity is an interface represent one aggregate in repository
type KafkaProvider ¶
type KafkaProvider struct {
// contains filtered or unexported fields
}
KafkaProvider implemented provider for kafka
func (*KafkaProvider) Close ¶ added in v0.2.1
func (p *KafkaProvider) Close()
Close just close producer instance
func (*KafkaProvider) FetchAllEvents ¶
func (p *KafkaProvider) FetchAllEvents(batch int) (<-chan []goeh.Event, error)
FetchAllEvents get all events from all partitions from specified topic
func (*KafkaProvider) SendEvents ¶
func (p *KafkaProvider) SendEvents(events []goeh.Event) error
SendEvents put messages on kafka topic
type MemoryRepository ¶
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository is an basic implementation of Repository which keep data in the memory. This struct waiting for inheritance by own Repository. Inherited implementation should contains special methods for each needed case of event type
func NewMemoryRepository ¶
func NewMemoryRepository() *MemoryRepository
NewMemoryRepository create empty initialized instance
func (*MemoryRepository) AddNewEvent ¶
func (r *MemoryRepository) AddNewEvent(event goeh.Event)
AddNewEvent set newly created event to uncommitted list of events
func (*MemoryRepository) AddOrModifyEntity ¶
func (r *MemoryRepository) AddOrModifyEntity(entity Entity)
AddOrModifyEntity just set new entity to collections of Entities. It will be replace if this id exists
func (*MemoryRepository) GetEntity ¶
func (r *MemoryRepository) GetEntity(id string) (Entity, error)
GetEntity return current entity state provided by id
func (*MemoryRepository) GetUncommitedChanges ¶
func (r *MemoryRepository) GetUncommitedChanges() []goeh.Event
GetUncommitedChanges get new events which were created by changes methods
func (*MemoryRepository) InitProvider ¶
func (r *MemoryRepository) InitProvider(provider Provider, child Repository) error
InitProvider set event store provider to repository and start restore entities
type Provider ¶
type Provider interface { FetchAllEvents(batch int) (<-chan []goeh.Event, error) SendEvents(events []goeh.Event) error Close() }
Provider interface
func NewKafkaProvider ¶
func NewKafkaProvider(topic string, groupName string, servers string, eventsMapper *goeh.EventsMapper) Provider
NewKafkaProvider create new instance of provider
type Repository ¶
type Repository interface { InitProvider(provider Provider, child Repository) error // ?? AddOrModifyEntity(entity Entity) GetEntity(id string) (Entity, error) Replay(events []goeh.Event) error AddNewEvent(event goeh.Event) GetUncommitedChanges() []goeh.Event Save(events []goeh.Event) error }
Repository it's an abstraction for database which keeps all entities (aggregators) in theirs last state