version

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultMinVersionDeadline = 10 * time.Second

DefaultMinVersionDeadline is the deadline to use when creating a min version context that waits.

Functions

func MinVersionFromContext added in v0.8.0

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

MinVersionFromContext returns the min version from the context.

func NewContextWithMinVersion added in v0.8.0

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

NewContextWithMinVersion returns the context with min version set.

func NewContextWithMinVersionWait added in v0.8.0

func NewContextWithMinVersionWait(ctx context.Context, minVersion int) (c context.Context, cancel func())

NewContextWithMinVersionWait returns the context with min version and a default deadline set.

Types

type Repo

type Repo struct {
	eh.ReadWriteRepo
}

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

func IntoRepo added in v0.14.0

func IntoRepo(ctx context.Context, repo eh.ReadRepo) *Repo

IntoRepo tries to convert a eh.ReadRepo into a Repo by recursively looking at inner repos. Returns nil if none was found.

func NewRepo

func NewRepo(repo eh.ReadWriteRepo) *Repo

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.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 repeatedly try to get the item until either the version matches or the deadline is reached.

func (*Repo) InnerRepo added in v0.14.0

func (r *Repo) InnerRepo(ctx context.Context) eh.ReadRepo

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

Jump to

Keyboard shortcuts

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