dynamodb

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

Build Status Coverage Status GoDoc Go Report Card

Event Horizon Dynamo

Event Horizon Dynamo contains the DynamoDB driver for Event Horizon a CQRS/ES toolkit for Go.

Usage

See the Event Horizon example folder for a few examples to get you started and replace the storage drivers (event store and/or repo)

Development

To develop Event Horizon Dynamo you need to have Docker and Docker Compose installed.

To start all needed services and run all tests, simply run make:

make

To manually run the services and stop them:

make services
make stop

When the services are running testing can be done either locally or with Docker:

make test
make test_docker
go test ./...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotClearDB = errors.New("could not clear database")

ErrCouldNotClearDB is when the database could not be cleared.

View Source
var ErrCouldNotDialDB = errors.New("could not dial database")

ErrCouldNotDialDB is when the database could not be dialed.

View Source
var ErrCouldNotMarshalEvent = errors.New("could not marshal event")

ErrCouldNotMarshalEvent is when an event could not be marshaled into BSON.

View Source
var ErrCouldNotSaveAggregate = errors.New("could not save aggregate")

ErrCouldNotSaveAggregate is when an aggregate could not be saved.

View Source
var ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal event")

ErrCouldNotUnmarshalEvent is when an event could not be unmarshaled into a concrete type.

View Source
var ErrModelNotSet = errors.New("model not set")

ErrModelNotSet is when an model factory is not set on the Repo.

Functions

This section is empty.

Types

type EventStore

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

EventStore implements an EventStore for DynamoDB.

func NewEventStore

func NewEventStore(config *EventStoreConfig) (*EventStore, error)

NewEventStore creates a new EventStore.

func NewEventStoreWithDB added in v0.1.2

func NewEventStoreWithDB(config *EventStoreConfig, db *dynamo.DB) *EventStore

NewEventStoreWithDB creates a new EventStore with DB

func (*EventStore) CreateTable

func (s *EventStore) CreateTable(ctx context.Context) error

CreateTable creates the table if it is not already existing and correct.

func (*EventStore) DeleteTable

func (s *EventStore) DeleteTable(ctx context.Context) error

DeleteTable deletes the event table.

func (*EventStore) Load

func (s *EventStore) Load(ctx context.Context, id uuid.UUID) ([]eh.Event, error)

Load implements the Load method of the eventhorizon.EventStore interface.

func (*EventStore) LoadAll added in v0.1.4

func (s *EventStore) LoadAll(ctx context.Context) ([]eh.Event, error)

LoadAll will load all the events from the event store (useful to replay events)

func (*EventStore) RenameEvent

func (s *EventStore) RenameEvent(ctx context.Context, from, to eh.EventType) error

RenameEvent implements the RenameEvent method of the eventhorizon.EventStore interface.

func (*EventStore) Replace

func (s *EventStore) Replace(ctx context.Context, event eh.Event) error

Replace implements the Replace method of the eventhorizon.EventStore interface.

func (*EventStore) Save

func (s *EventStore) Save(ctx context.Context, events []eh.Event, originalVersion int) error

Save implements the Save method of the eventhorizon.EventStore interface.

func (*EventStore) TableName added in v0.1.2

func (s *EventStore) TableName(ctx context.Context) string

TableName appends the namespace, if one is set, to the table prefix to get the name of the table to use.

type EventStoreConfig

type EventStoreConfig struct {
	TablePrefix string
	Region      string
	Endpoint    string
}

EventStoreConfig is a config for the DynamoDB event store.

type IndexInput added in v0.1.5

type IndexInput struct {
	IndexName         string
	PartitionKey      string
	PartitionKeyValue interface{}
	SortKey           string
	SortKeyValue      interface{}
}

IndexInput is all the params we need to filter on an index

type Repo

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

Repo implements a DynamoDB repository for entities.

func NewRepo

func NewRepo(config *RepoConfig) (*Repo, error)

NewRepo creates a new Repo.

func (*Repo) Find

func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)

Find implements the Find method of the eventhorizon.ReadRepo interface.

func (*Repo) FindAll

func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error)

FindAll implements the FindAll method of the eventhorizon.ReadRepo interface.

func (*Repo) FindWithFilter added in v0.1.2

func (r *Repo) FindWithFilter(ctx context.Context, expr string, args ...interface{}) ([]eh.Entity, error)

FindWithFilter allows to find entities with a filter

func (*Repo) FindWithFilterUsingIndex added in v0.1.5

func (r *Repo) FindWithFilterUsingIndex(ctx context.Context, indexInput IndexInput, filterQuery string, filterArgs ...interface{}) ([]eh.Entity, error)

FindWithFilterUsingIndex allows to find entities with a filter using an index

func (*Repo) Parent

func (r *Repo) Parent() eh.ReadRepo

Parent implements the Parent method of the eventhorizon.ReadRepo interface.

func (*Repo) Remove

func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error

Remove implements the Remove method of the eventhorizon.WriteRepo interface.

func (*Repo) Save

func (r *Repo) Save(ctx context.Context, entity eh.Entity) error

Save implements the Save method of the eventhorizon.WriteRepo interface.

func (*Repo) SetEntityFactory

func (r *Repo) SetEntityFactory(f func() eh.Entity)

SetEntityFactory sets a factory function that creates concrete entity types.

type RepoConfig

type RepoConfig struct {
	TableName string
	Region    string
	Endpoint  string
}

RepoConfig is a config for the DynamoDB event store.

Jump to

Keyboard shortcuts

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