Documentation ¶
Index ¶
- Constants
- func ConvertError(err error, entity string, keyFmt string, args ...interface{}) error
- func GetEventTenant(event eh.Event) string
- func IsEHNotFound(err error) bool
- func WithTenant(ctx context.Context) eh.EventOption
- type EntityHealer
- type ReadModelRegenerator
- func (r *ReadModelRegenerator) HandleCommand(ctx context.Context, command eh.Command) error
- func (r *ReadModelRegenerator) Regenerate(ctx context.Context, aggType eh.AggregateType, id uuid.UUID) error
- func (r *ReadModelRegenerator) Register(ctx context.Context, aggType eh.AggregateType, prj *projector.EventHandler, ...) error
- type ReadRepo
- type RegenerateReadModelsCmd
Constants ¶
const (
RegenerateReadModelsCmdType eh.CommandType = "RegenerateReadModelsCmd"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertError ¶ added in v2.2.1
ConvertError convert Event Horizon errors to standard format
func GetEventTenant ¶ added in v2.1.0
GetEventTenant returns the tenant of the event, or the default tenant if not found
func IsEHNotFound ¶
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
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 (*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 ¶
func (r *ReadModelRegenerator) Register(ctx context.Context, aggType eh.AggregateType, prj *projector.EventHandler, repo eh.ReadWriteRepo) error
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