xeh

package
v2.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegenerateReadModelsCmdType eh.CommandType = "RegenerateReadModelsCmd"
)

Variables

This section is empty.

Functions

func ConvertError added in v2.2.1

func ConvertError(err error, entity string, keyFmt string, args ...interface{}) error

ConvertError convert Event Horizon errors to standard format

func GetEventTenant added in v2.1.0

func GetEventTenant(event eh.Event) string

GetEventTenant returns the tenant of the event, or the default tenant if not found

func IsEHNotFound

func IsEHNotFound(err error) bool

func WithTenant added in v2.1.0

func WithTenant(ctx context.Context) eh.EventOption

WithTenant adds the tenant to the event metadata

Types

type EntityHealer added in v2.4.0

type EntityHealer struct {
	*projector.EventHandler
	// contains filtered or unexported fields
}

EntityHealer is a healer of entities of the read model. It wraps a Projector to recreate a read model from the event store in case of a failure eh.ErrIncorrectEntityVersion.

func NewEntityHealer added in v2.4.0

func NewEntityHealer(logger *zap.Logger, eventStore eh.EventStore, prj projector.Projector, repo eh.ReadWriteRepo, options ...projector.Option) *EntityHealer

func (*EntityHealer) HandleEvent added in v2.4.0

func (h *EntityHealer) HandleEvent(ctx context.Context, event eh.Event) error

type ReadModelRegenerator

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

ReadModelRegenerator is a command handler that regenerates read models

func NewReadModelRegenerator

func NewReadModelRegenerator(eventStore eh.EventStore, logger *zap.Logger) *ReadModelRegenerator

NewReadModelRegenerator creates a new ReadModelRegenerator that reads old events from the given event store

func (*ReadModelRegenerator) HandleCommand

func (r *ReadModelRegenerator) HandleCommand(ctx context.Context, command eh.Command) error

func (*ReadModelRegenerator) Regenerate

func (r *ReadModelRegenerator) Regenerate(ctx context.Context, aggType eh.AggregateType, id uuid.UUID) error

Regenerate removes the read model and reapply all events to get a refreshed read model.

func (*ReadModelRegenerator) Register

Register registers a projector for a given aggregate type to allow the regeneration of its read models. Multiple projectors of seam read model can be registered for the same aggregate type. Also, multiple aggregate types can be registered.

type ReadRepo

type ReadRepo[Entity eh.Entity] interface {
	// InnerRepo returns the inner read repository, if there is one.
	// Useful for iterating a wrapped set of repositories to get a specific one.
	InnerRepo(context.Context) eh.ReadRepo

	// Find returns an entity for an Id.
	Find(context.Context, uuid.UUID) (Entity, error)

	// FindAll returns all entities in the repository.
	FindAll(context.Context) ([]Entity, error)

	// Close closes the ReadRepo.
	Close() error
}

type RegenerateReadModelsCmd

type RegenerateReadModelsCmd struct {
	ID   uuid.UUID
	Type eh.AggregateType
}

RegenerateReadModelsCmd is a command that removes a read model and reapply all events to get a refreshed read model. This action will collide with current transactions. Execute it with caution. The action is idempotent. It can be executed multiple times without side effects.

To regenerate a read model, first register a projector for the aggregate type, then send this command.

func (RegenerateReadModelsCmd) AggregateID

func (r RegenerateReadModelsCmd) AggregateID() uuid.UUID

func (RegenerateReadModelsCmd) AggregateType

func (r RegenerateReadModelsCmd) AggregateType() eh.AggregateType

func (RegenerateReadModelsCmd) CommandType

func (r RegenerateReadModelsCmd) CommandType() eh.CommandType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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