Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIncorrectModelVersion = errors.New("incorrect model version")
ErrIncorrectModelVersion is when a model has an incorrect version.
var ErrModelHasNoVersion = errors.New("model has no version")
ErrModelHasNoVersion is when a model has no version number.
Functions ¶
func MinVersion ¶
MinVersion returns the min version from the context.
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 ¶
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().