domain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateRestaurantCommandType CreateRestaurantCommand type
	CreateRestaurantCommandType = eh.CommandType("restaurant:create")
	// ChangeRestaurantNameCommandType ChangeRestaurantNameCommand type
	ChangeRestaurantNameCommandType = eh.CommandType("restaurant:change_name")
)
View Source
const (
	// Created is the event after a restaurant is created
	Created = eh.EventType("restaurant:created")
	// Deleted is the event after a restaurant is deleted
	Deleted = eh.EventType("restaurant:deleted")
	// NameChanged is the event after a restaurant name is changed
	NameChanged = eh.EventType("restaurant:name_changed")
)
View Source
const RestaurantAggregateType = eh.AggregateType("restaurant")

RestaurantAggregateType is the type for the restaurant aggregate

Variables

View Source
var TimeNow = time.Now

TimeNow is a mockable version of time.Now.

Functions

func Setup

func Setup(
	eventStore eh.EventStore,
	eventBus eh.EventBus,
	commandBus *bus.CommandHandler)

Setup configures the domain.

Types

type ChangeRestaurantNameCommand

type ChangeRestaurantNameCommand struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

ChangeRestaurantNameCommand creates a restaurant

func (*ChangeRestaurantNameCommand) AggregateID

func (c *ChangeRestaurantNameCommand) AggregateID() uuid.UUID

AggregateID stub

func (*ChangeRestaurantNameCommand) AggregateType

func (c *ChangeRestaurantNameCommand) AggregateType() eh.AggregateType

AggregateType stub

func (*ChangeRestaurantNameCommand) CommandType

func (c *ChangeRestaurantNameCommand) CommandType() eh.CommandType

CommandType stub

type CreateRestaurantCommand

type CreateRestaurantCommand struct {
	ID uuid.UUID `json:"id"`
}

CreateRestaurantCommand creates a restaurant

func (*CreateRestaurantCommand) AggregateID

func (c *CreateRestaurantCommand) AggregateID() uuid.UUID

AggregateID stub

func (*CreateRestaurantCommand) AggregateType

func (c *CreateRestaurantCommand) AggregateType() eh.AggregateType

AggregateType stub

func (*CreateRestaurantCommand) CommandType

func (c *CreateRestaurantCommand) CommandType() eh.CommandType

CommandType stub

type NameChangedData

type NameChangedData struct {
	Name string `json:"name" bson:"name"`
}

NameChangedData contains the data for NameChanged event

type RestaurantAggregate

type RestaurantAggregate struct {
	*events.AggregateBase
	// contains filtered or unexported fields
}

RestaurantAggregate is the aggregate for restaurant

func (*RestaurantAggregate) ApplyEvent

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

ApplyEvent implements the ApplyEvent method of the eventhorizon.Aggregate interface.

func (*RestaurantAggregate) HandleCommand

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

HandleCommand implements the HandleCommand method of the eventhorizon.CommandHandler interface.

Jump to

Keyboard shortcuts

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