Documentation ¶
Index ¶
- Constants
- func IsEHNotFound(err error) bool
- 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 IsEHNotFound ¶
Types ¶
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