guestlist

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateInviteCommand eh.CommandType = "CreateInvite"

	AcceptInviteCommand  eh.CommandType = "AcceptInvite"
	DeclineInviteCommand eh.CommandType = "DeclineInvite"

	ConfirmInviteCommand eh.CommandType = "ConfirmInvite"
	DenyInviteCommand    eh.CommandType = "DenyInvite"
)
View Source
const (
	// InviteCreatedEvent is when an invite is created.
	InviteCreatedEvent eh.EventType = "InviteCreated"

	// InviteAcceptedEvent is when an invite has been accepted by the guest.
	InviteAcceptedEvent eh.EventType = "InviteAccepted"
	// InviteDeclinedEvent is when an invite has been declined by the guest.
	InviteDeclinedEvent eh.EventType = "InviteDeclined"

	// InviteConfirmedEvent is when an invite has been cornfirmed as booked.
	InviteConfirmedEvent eh.EventType = "InviteConfirmed"
	// InviteDeniedEvent is when an invite has been declined to be booked.
	InviteDeniedEvent eh.EventType = "InviteDenied"
)
View Source
const InvitationAggregateType eh.AggregateType = "Invitation"

InvitationAggregateType is the type name of the aggregate.

View Source
const ResponseSagaType saga.Type = "ResponseSaga"

ResponseSagaType is the type of the saga.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(h eh.CommandHandler) eh.CommandHandler

LoggingMiddleware is a tiny command handle middleware for logging.

func Setup

func Setup(
	ctx context.Context,
	eventStore eh.EventStore,
	eventBus eh.EventBus,
	commandBus *bus.CommandHandler,
	invitationRepo, guestListRepo eh.ReadWriteRepo,
	eventID uuid.UUID)

Setup configures the guestlist.

Types

type AcceptInvite

type AcceptInvite struct {
	ID uuid.UUID
}

AcceptInvite is a command for accepting invites.

func (AcceptInvite) AggregateID

func (c AcceptInvite) AggregateID() uuid.UUID

func (AcceptInvite) AggregateType

func (c AcceptInvite) AggregateType() eh.AggregateType

func (AcceptInvite) CommandType

func (c AcceptInvite) CommandType() eh.CommandType

type ConfirmInvite

type ConfirmInvite struct {
	ID uuid.UUID
}

ConfirmInvite is a command for confirming invites.

func (ConfirmInvite) AggregateID

func (c ConfirmInvite) AggregateID() uuid.UUID

func (ConfirmInvite) AggregateType

func (c ConfirmInvite) AggregateType() eh.AggregateType

func (ConfirmInvite) CommandType

func (c ConfirmInvite) CommandType() eh.CommandType

type CreateInvite

type CreateInvite struct {
	ID   uuid.UUID
	Name string
	Age  int `eh:"optional"`
}

CreateInvite is a command for creating invites.

func (CreateInvite) AggregateID

func (c CreateInvite) AggregateID() uuid.UUID

func (CreateInvite) AggregateType

func (c CreateInvite) AggregateType() eh.AggregateType

func (CreateInvite) CommandType

func (c CreateInvite) CommandType() eh.CommandType

type DeclineInvite

type DeclineInvite struct {
	ID uuid.UUID
}

DeclineInvite is a command for declining invites.

func (DeclineInvite) AggregateID

func (c DeclineInvite) AggregateID() uuid.UUID

func (DeclineInvite) AggregateType

func (c DeclineInvite) AggregateType() eh.AggregateType

func (DeclineInvite) CommandType

func (c DeclineInvite) CommandType() eh.CommandType

type DenyInvite

type DenyInvite struct {
	ID uuid.UUID
}

DenyInvite is a command for denying invites.

func (DenyInvite) AggregateID

func (c DenyInvite) AggregateID() uuid.UUID

func (DenyInvite) AggregateType

func (c DenyInvite) AggregateType() eh.AggregateType

func (DenyInvite) CommandType

func (c DenyInvite) CommandType() eh.CommandType

type GuestList

type GuestList struct {
	ID           uuid.UUID `bson:"_id"`
	NumGuests    int
	NumAccepted  int
	NumDeclined  int
	NumConfirmed int
	NumDenied    int
}

GuestList is a read model object for the guest list.

func (*GuestList) EntityID

func (g *GuestList) EntityID() uuid.UUID

EntityID implements the EntityID method of the eventhorizon.Entity interface.

type GuestListProjector

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

GuestListProjector is a projector that updates the guest list. It is implemented as a manual projector, not using the Projector interface.

func NewGuestListProjector

func NewGuestListProjector(repo eh.ReadWriteRepo, eventID uuid.UUID) *GuestListProjector

NewGuestListProjector creates a new GuestListProjector.

func (*GuestListProjector) HandleEvent

func (p *GuestListProjector) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the EventHandler interface.

func (*GuestListProjector) HandlerType

func (p *GuestListProjector) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.

type Invitation

type Invitation struct {
	ID      uuid.UUID `bson:"_id"`
	Version int
	Name    string
	Age     int
	Status  string
}

Invitation is a read model object for an invitation.

func (*Invitation) AggregateVersion

func (i *Invitation) AggregateVersion() int

AggregateVersion implements the AggregateVersion method of the eventhorizon.Versionable interface.

func (*Invitation) EntityID

func (i *Invitation) EntityID() uuid.UUID

EntityID implements the EntityID method of the eventhorizon.Entity interface.

type InvitationAggregate

type InvitationAggregate struct {
	// AggregateBase implements most of the eventhorizon.Aggregate interface.
	*events.AggregateBase
	// contains filtered or unexported fields
}

InvitationAggregate is the root aggregate.

The aggregate root will guard that the invitation can only be accepted OR declined, but not both.

func NewInvitationAggregate

func NewInvitationAggregate(id uuid.UUID) *InvitationAggregate

NewInvitationAggregate creates a new InvitationAggregate with an ID.

func (*InvitationAggregate) ApplyEvent

func (a *InvitationAggregate) ApplyEvent(ctx context.Context, event eh.Event) error

ApplyEvent implements the ApplyEvent method of the Aggregate interface.

func (*InvitationAggregate) HandleCommand

func (a *InvitationAggregate) HandleCommand(ctx context.Context, cmd eh.Command) error

HandleCommand implements the HandleCommand method of the Aggregate interface.

type InvitationProjector

type InvitationProjector struct{}

InvitationProjector is a projector that updates the invitations.

func NewInvitationProjector

func NewInvitationProjector() *InvitationProjector

NewInvitationProjector creates a new InvitationProjector.

func (*InvitationProjector) Project

func (p *InvitationProjector) Project(ctx context.Context, event eh.Event, entity eh.Entity) (eh.Entity, error)

Project implements the Project method of the Projector interface.

func (*InvitationProjector) ProjectorType

func (p *InvitationProjector) ProjectorType() projector.Type

ProjectorType implements the ProjectorType method of the Projector interface.

type InviteCreatedData

type InviteCreatedData struct {
	Name string `bson:"name"`
	Age  int    `bson:"age"`
}

InviteCreatedData is the event data for when an invite has been created.

type Logger

type Logger struct{}

Logger is a simple event handler for logging all events.

func (*Logger) HandleEvent

func (l *Logger) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the EventHandler interface.

func (*Logger) HandlerType

func (l *Logger) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.

type ResponseSaga

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

ResponseSaga is a saga that confirmes all accepted invites until a guest limit has been reached.

func NewResponseSaga

func NewResponseSaga(guestLimit int) *ResponseSaga

NewResponseSaga returns a new ResponseSage with a guest limit.

func (*ResponseSaga) RunSaga

func (s *ResponseSaga) RunSaga(ctx context.Context, event eh.Event, h eh.CommandHandler) error

RunSaga implements the Run saga method of the Saga interface.

func (*ResponseSaga) SagaType

func (s *ResponseSaga) SagaType() saga.Type

SagaType implements the SagaType method of the Saga interface.

Jump to

Keyboard shortcuts

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