version

package
v0.0.0-...-b205a7c Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectModelVersion = errors.New("incorrect model version")

ErrIncorrectModelVersion is when a model has an incorrect version.

View Source
var ErrModelHasNoVersion = errors.New("model has no version")

ErrModelHasNoVersion is when a model has no version number.

Functions

func MinVersion

func MinVersion(ctx context.Context) (int, bool)

MinVersion returns the min version from the context.

func WithMinVersion

func WithMinVersion(ctx context.Context, minVersion int) context.Context

WithMinVersion returns the context with min value set.

Types

type ReadRepository

type ReadRepository struct {
	eh.ReadRepository
}

ReadRepository is a middleware that adds version checking to a read repository.

func NewReadRepository

func NewReadRepository(repo eh.ReadRepository) *ReadRepository

NewReadRepository creates a new ReadRepository.

func Repository

func Repository(repo eh.ReadRepository) *ReadRepository

Repository returns a parent ReadRepository if there is one.

func (*ReadRepository) Find

func (r *ReadRepository) Find(ctx context.Context, id eh.UUID) (interface{}, error)

Find implements the Find method of the eventhorizon.ReadModel interface. If the context contains a min version set by WithMinVersion it will only return an item if its version is at least min version. If a timeout or deadline is set on the context it will repetedly try to get the item until either the version matches or the deadline is reached.

func (*ReadRepository) Parent

func (r *ReadRepository) Parent() eh.ReadRepository

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

type Versionable

type Versionable interface {
	// AggregateVersion returns the aggregate version that a read model represents.
	AggregateVersion() int
}

Versionable is a read model that has a version number saved, used by ReadRepository.FindMinVersion().

Jump to

Keyboard shortcuts

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