ehu

package
v0.0.0-...-4ca8788 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAggregateDeleted = errors.New("the aggregate has already been deleted")
View Source
var ErrCouldNotClearDB = errors.New("could not clear database")
View Source
var ErrCouldNotLoadAggregate = errors.New("could not load aggregate")
View Source
var ErrCouldNotMarshalEvent = errors.New("could not marshal dbEvent")
View Source
var ErrCouldNotSaveAggregate = errors.New("could not save aggregate")
View Source
var ErrCouldNotUnmarshalEvent = errors.New("could not unmarshal dbEvent")

Functions

func CommandHandlerNotImplemented

func CommandHandlerNotImplemented(commandType eventhorizon.CommandType) error

func ConvertToCommandTypes

func ConvertToCommandTypes(commands []enum.Literal) []eventhorizon.CommandType

func ConvertToEventTypes

func ConvertToEventTypes(events []enum.Literal) []eventhorizon.EventType

func EntityAlreadyExists

func EntityAlreadyExists(entityId uuid.UUID, aggregateType eventhorizon.AggregateType) error

func EntityChildIdNotDefined

func EntityChildIdNotDefined(entityId uuid.UUID, aggregateType eventhorizon.AggregateType, childType string) error

func EntityChildNotExists

func EntityChildNotExists(entityId uuid.UUID, aggregateType eventhorizon.AggregateType, childId uuid.UUID, childType string) error

func EntityNotExists

func EntityNotExists(entityId uuid.UUID, aggregateType eventhorizon.AggregateType) error

func EventHandlerNotImplemented

func EventHandlerNotImplemented(eventType eventhorizon.EventType) error

func IdNotDefined

func IdNotDefined(currentId uuid.UUID, aggregateType eventhorizon.AggregateType) error

func IdsDismatch

func IdsDismatch(entityId uuid.UUID, currentId uuid.UUID, aggregateType eventhorizon.AggregateType) error

func NewErrCouldNotLoadAggregate

func NewErrCouldNotLoadAggregate(_ context.Context, err error) error

func NewErrCouldNotMarshalEvent

func NewErrCouldNotMarshalEvent(_ context.Context, err error) error

func NewErrCouldNotSaveAggregate

func NewErrCouldNotSaveAggregate(_ context.Context, err error) error

func NewErrCouldNotUnmarshalEvent

func NewErrCouldNotUnmarshalEvent(_ context.Context, err error) error

func NewErrIncorrectEventVersion

func NewErrIncorrectEventVersion(_ context.Context) error

func QueryNotImplemented

func QueryNotImplemented(queryName string) error

func ValidateIdsMatch

func ValidateIdsMatch(entityId uuid.UUID, currentId uuid.UUID, aggregateType eventhorizon.AggregateType) (ret error)

func ValidateNewId

func ValidateNewId(entityId uuid.UUID, currentId uuid.UUID, aggregateType eventhorizon.AggregateType) (ret error)

Types

type AggregateEngine

type AggregateEngine struct {
	*Middleware

	AggregateType    eventhorizon.AggregateType
	AggregateFactory func(id uuid.UUID) eventhorizon.Aggregate
	EntityFactory    func() eventhorizon.Entity

	Commands []eventhorizon.CommandType
	Events   []eventhorizon.EventType
	// contains filtered or unexported fields
}

func NewAggregateEngine

func NewAggregateEngine(middelware *Middleware,
	aggregateType eventhorizon.AggregateType,
	aggregateFactory func(id uuid.UUID) eventhorizon.Aggregate,
	entityFactory func() eventhorizon.Entity,
	commands []enum.Literal, events []enum.Literal) (ret *AggregateEngine)

func (*AggregateEngine) RegisterForEvent

func (o *AggregateEngine) RegisterForEvent(handler eventhorizon.EventHandler, event enum.Literal) (err error)

func (*AggregateEngine) RegisterForEvents

func (o *AggregateEngine) RegisterForEvents(handler eventhorizon.EventHandler, events []eventhorizon.EventType) (err error)

func (*AggregateEngine) RegisterForEventsAll

func (o *AggregateEngine) RegisterForEventsAll(handler eventhorizon.EventHandler) (err error)

func (*AggregateEngine) RegisterProjector

func (o *AggregateEngine) RegisterProjector(projectorType string, listener DelegateEventHandler) (ret *ProjectorEventHandler, err error)

func (*AggregateEngine) RegisterSagaForEvents

func (o *AggregateEngine) RegisterSagaForEvents(aSaga saga.Saga, events []eventhorizon.EventType) (err error)

func (*AggregateEngine) Setup

func (o *AggregateEngine) Setup() (err error)

type AggregateStoreEvent

type AggregateStoreEvent interface {
	AppendEvent(eventhorizon.EventType, eventhorizon.EventData, time.Time, ...eventhorizon.EventOption) eventhorizon.Event
}

type CommandError

type CommandError struct {
	Err    error
	Cmd    eh.Command
	Entity eh.Entity
}

func (CommandError) Cause

func (o CommandError) Cause() error

func (CommandError) Error

func (o CommandError) Error() string

type DelegateCommandHandler

type DelegateCommandHandler interface {
	CommandTypes() []eventhorizon.CommandType
	Execute(cmd eventhorizon.Command, entity eventhorizon.Entity, store AggregateStoreEvent) error
}

type DelegateEventHandler

type DelegateEventHandler interface {
	EventTypes() []eventhorizon.EventType
	Apply(event eventhorizon.Event, entity eventhorizon.Entity) error
}

type Entity

type Entity interface {
	EntityID() uuid.UUID
	Deleted() *time.Time
}

type EventStoreDelegate

type EventStoreDelegate struct {
	Factory func() (ret eventhorizon.EventStore, err error)
	// contains filtered or unexported fields
}

func (*EventStoreDelegate) Close

func (o *EventStoreDelegate) Close() (err error)

func (*EventStoreDelegate) Load

func (o *EventStoreDelegate) Load(ctx context.Context, id uuid.UUID) (ret []eventhorizon.Event, err error)

func (*EventStoreDelegate) LoadFrom

func (o *EventStoreDelegate) LoadFrom(ctx context.Context, id uuid.UUID, version int) (
	ret []eventhorizon.Event, err error)

LoadFrom loads all events from version for the aggregate id from the store.

func (*EventStoreDelegate) Save

func (o *EventStoreDelegate) Save(ctx context.Context, events []eventhorizon.Event, originalVersion int) (err error)

type HttpCommandHandler

type HttpCommandHandler struct {
	Context    context.Context
	CommandBus eventhorizon.CommandHandler
}

func NewHttpCommandHandlerFull

func NewHttpCommandHandlerFull(
	context context.Context, commandBus eventhorizon.CommandHandler) (ret *HttpCommandHandler)

func (*HttpCommandHandler) HandleCommand

func (o *HttpCommandHandler) HandleCommand(command eventhorizon.Command, w http.ResponseWriter, r *http.Request)

type HttpQueryHandler

type HttpQueryHandler struct {
}

func NewHttpQueryHandlerFull

func NewHttpQueryHandlerFull() (ret *HttpQueryHandler)

func (*HttpQueryHandler) HandleResult

func (o *HttpQueryHandler) HandleResult(
	ret interface{}, err error, method string, w http.ResponseWriter, r *http.Request)

type Middleware

type Middleware struct {
	EventStore eventhorizon.EventStore
	EventBus   eventhorizon.EventBus
	CommandBus *bus.CommandHandler
	Repos      func(string, func() (ret eventhorizon.Entity)) (ret eventhorizon.ReadWriteRepo, err error)
}

type ProjectorEventHandler

type ProjectorEventHandler struct {
	DelegateEventHandler
	Repo eventhorizon.ReadRepo
	// contains filtered or unexported fields
}

func NewProjector

func NewProjector(projectorType string, eventHandler DelegateEventHandler, repo eventhorizon.ReadRepo) (ret *ProjectorEventHandler)

func (*ProjectorEventHandler) Project

func (*ProjectorEventHandler) ProjectorType

func (o *ProjectorEventHandler) ProjectorType() projector.Type

Directories

Path Synopsis
app

Jump to

Keyboard shortcuts

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