eventsourcing

package
v0.0.0-...-4ebf5ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EventSourcedNoFound = errors.New("eventsoucing no found")
)

Functions

func GetPartitionKey

func GetPartitionKey(sourceType string, id types.Guid) string

func RegisterVersionEventFactory

func RegisterVersionEventFactory(key string, vef VersionEventFactory)

func WithRepository

func WithRepository(parent context.Context, repo Repository) context.Context

Types

type EventEntity

type EventEntity struct {
	Id           int64 `gorm:"primary_key"`
	PartitionKey string
	SourceType   string
	EventType    string

	SourceId      string
	CorrelationId string
	Version       int64
	Payload       string
}

event entity

func ToData

func ToData(st string, partitionKey string, e VersionedEvent) (*EventEntity, error)

func (*EventEntity) TableName

func (ed *EventEntity) TableName() string

type EventSourced

type EventSourced interface {
	Id() types.Guid
	Version() int64
	ApplyEvent(ve VersionedEvent) error
	Events() []VersionedEvent
	Payload() []byte
}

type EventSourcedRepository

type EventSourcedRepository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(es EventStore) *EventSourcedRepository

func (*EventSourcedRepository) Find

func (esr *EventSourcedRepository) Find(id types.Guid, es EventSourced) (err error)

func (*EventSourcedRepository) Save

func (esr *EventSourcedRepository) Save(es EventSourced, correlationId string) error

type EventStore

type EventStore interface {
	Load(partitionKey string, version int64) ([]*EventEntity, error)
	Save(partitionKey string, events []*EventEntity) error
}

type Repository

type Repository interface {
	Find(id types.Guid, es EventSourced) (err error)
	Save(es EventSourced, correlationId string) error
}

func RepositoryInContext

func RepositoryInContext(ctx context.Context) Repository

type TrivialVersionedEvent

type TrivialVersionedEvent struct {
	// contains filtered or unexported fields
}

trivival versioned event

func (*TrivialVersionedEvent) SourceId

func (tve *TrivialVersionedEvent) SourceId() types.Guid

func (*TrivialVersionedEvent) Version

func (tve *TrivialVersionedEvent) Version() int64

type VersionEventFactory

type VersionEventFactory interface {
	NewVersionEvent(sourceId types.Guid, version int64) VersionedEvent
}

func GetVersionEventFactory

func GetVersionEventFactory(key string) VersionEventFactory

type VersionEventFactoryFunc

type VersionEventFactoryFunc func(sourceId types.Guid, version int64) VersionedEvent

func (VersionEventFactoryFunc) NewVersionEvent

func (veff VersionEventFactoryFunc) NewVersionEvent(sourceId types.Guid, version int64) VersionedEvent

type VersionedEvent

type VersionedEvent interface {
	event.Event
	Version() int64
}

func NewVersionEvent

func NewVersionEvent(sourceId types.Guid, version int64) VersionedEvent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL