eventsource

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDeleted   = errors.New("Not found (was deleted)")
	ErrNoHistory = errors.New("No history found")
)

Functions

This section is empty.

Types

type Aggregate

type Aggregate interface {
	On(ctx context.Context, event Event) error
	SetAggregateID(id string)
}

Aggregate is a interface

type AggregatorMock

type AggregatorMock struct {
	Mock *mock.Mock
}

AggregatorMock is a mock

func CreateAggregatorMock

func CreateAggregatorMock() *AggregatorMock

CreateAggregatorMock returns a aggregatorMock

func (AggregatorMock) On

func (o AggregatorMock) On(ctx context.Context, event Event) error

On is a mock

func (AggregatorMock) SetAggregateID

func (o AggregatorMock) SetAggregateID(id string)

SetAggregateID is not implemented

type BaseEvent

type BaseEvent struct {
	AggregateID string `json:"aggregateId"`
	UserID      string `json:"userId"`
}

BaseEvent ...

func (BaseEvent) GetAggregateID

func (e BaseEvent) GetAggregateID() string

GetAggregateID ...

func (BaseEvent) GetUserID

func (e BaseEvent) GetUserID() string

GetUserID ...

type Event

type Event interface {
	GetAggregateID() string
	GetUserID() (userID string)
}

Event ...

type EventOnSave

type EventOnSave interface {
	OnSave(Record) error
}

type EventOnSaveWithContext

type EventOnSaveWithContext interface {
	OnSave(context.Context, Record) error
}

type Record

type Record struct {
	AggregateID string    `json:"aggregateId"`
	SequenceID  string    `json:"sequenceId"`
	Timestamp   time.Time `json:"timestamp" dynamodbav:",unixtime"`
	Type        string    `json:"type"`
	Data        []byte    `json:"data"`
	UserID      string    `json:"userId"`
}

Record is a store row

type Repository

type Repository interface {
	Save(events ...Event) (err error)
	SaveWithContext(ctx context.Context, events ...Event) (err error)
	Load(id string, aggr Aggregate) (deleted bool, err error)
	LoadWithContext(ctx context.Context, id string, aggr Aggregate) (deleted bool, err error)
}

Repository is a interface

func NewRepository

func NewRepository(store Store, serializer Serializer) Repository

NewRepository returns a new repository

type RepositoryMock

type RepositoryMock struct {
	*mock.Mock
}

RepositoryMock is a mock

func CreateRepositoryMock

func CreateRepositoryMock() *RepositoryMock

CreateRepositoryMock returns a repositoryMock

func (RepositoryMock) Load

func (r RepositoryMock) Load(id string, aggr Aggregate) (deleted bool, err error)

Load is a mock

func (RepositoryMock) LoadWithContext

func (r RepositoryMock) LoadWithContext(ctx context.Context, id string, aggr Aggregate) (deleted bool, err error)

LoadWithContext is a mock

func (RepositoryMock) Save

func (r RepositoryMock) Save(events ...Event) (err error)

Save is a mock

func (RepositoryMock) SaveWithContext

func (r RepositoryMock) SaveWithContext(ctx context.Context, events ...Event) (err error)

SaveWithContext is a mock

type Serializer

type Serializer interface {
	Unmarshal(data []byte, eventType string) (event Event, err error)
	Marshal(event Event) (data []byte, err error)
}

Serializer is a interface

type SerializerMock

type SerializerMock struct {
	*mock.Mock
}

SerializerMock is a mock

func CreateSerializerMock

func CreateSerializerMock() *SerializerMock

CreateSerializerMock returns a serializerMock

func (SerializerMock) Marshal

func (o SerializerMock) Marshal(event Event) (data []byte, err error)

Marshal returns the JSON encoding of event.

func (SerializerMock) Unmarshal

func (o SerializerMock) Unmarshal(data []byte, eventType string) (event Event, err error)

Unmarshal parses the JSON-encoded data and returns an event

type Store

type Store interface {
	Save(record Record) error
	SaveWithContext(ctx context.Context, record Record) error
	Load(id string) (record []Record, err error)
	LoadWithContext(ctx context.Context, id string) (record []Record, err error)
}

Store is a interface

type StoreMock

type StoreMock struct {
	*mock.Mock
}

StoreMock is a mock

func CreateStoreMock

func CreateStoreMock() *StoreMock

CreateStoreMock returns a storeMock

func (StoreMock) Load

func (o StoreMock) Load(id string) (record []Record, err error)

Load is a mock

func (StoreMock) LoadWithContext

func (o StoreMock) LoadWithContext(ctx context.Context, id string) (record []Record, err error)

LoadWithContext is a mock

func (StoreMock) Save

func (o StoreMock) Save(record Record) error

Save is a mock

func (StoreMock) SaveWithContext

func (o StoreMock) SaveWithContext(ctx context.Context, record Record) error

SaveWithContext is a mock

Directories

Path Synopsis
serializers
stores

Jump to

Keyboard shortcuts

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