builtin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AggregateDeleted = "goes.command.aggregate.deleted"

AggregateDeleted is published when an aggregate has been deleted.

View Source
const DeleteAggregateCmd = "goes.command.aggregate.delete"

DeleteAggregateCmd is the name of the DeleteAggregate command.

Variables

This section is empty.

Functions

func DeleteAggregate

func DeleteAggregate(name string, id uuid.UUID) command.Command

DeleteAggregate returns the command to delete an aggregate. When using the built-in command handler of this package, aggregates are deleted by deleting their events from the event store. Additionally, a "goes.command.aggregate.deleted" is published after deletion.

func Handle

func Handle(ctx context.Context, bus command.Bus, repo aggregate.Repository, opts ...HandleOption) (<-chan error, error)

Handle registers command handlers for the built-in commands and returns a channel of asynchronous command errors, or a single error if it fails to register the commands. When ctx is canceled, command handling stops and the returned error channel is closed.

The following commands are handled:

  • DeleteAggregateCmd ("goes.command.aggregate.delete")

func MustHandle

func MustHandle(ctx context.Context, bus command.Bus, repo aggregate.Repository, opts ...HandleOption) <-chan error

MustHandle does the same as Handle, but panic if command registration fails.

func RegisterCommands

func RegisterCommands(r *codec.Registry)

RegisterCommands registers the built-in commands into a command registry.

func RegisterEvents

func RegisterEvents(r *codec.Registry)

RegisterEvents registers events of built-in commands into an event registry.

Types

type AggregateDeletedData

type AggregateDeletedData struct {
	// Version is the version of the deleted aggregate.
	//
	// The AggregateVersion() returned by an AggregateDeleted event always
	// returns 0. Use this Version to see which version the aggregate has before
	// it was deleted.
	Version int
}

AggregateDeletedData is the event data for the AggregateDeleted event.

type DeleteAggregatePayload

type DeleteAggregatePayload struct{}

DeleteAggregatePayload is the command payload for deleting an aggregate.

type HandleOption

type HandleOption func(*handleConfig)

HandleOption is an option for Handle & MustHandle.

func PublishEvents

func PublishEvents(bus event.Bus, store event.Store) HandleOption

PublishEvents returns a HandleOption that configures the command handler to publish events over the provided Bus when appropriate. If the optional store is non-nil, the events are also inserted into store after publishing.

The following events are published by the handler:

  • AggregateDeleted ("goes.command.aggregate.deleted")

Jump to

Keyboard shortcuts

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