bus

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

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHandlerAlreadySet is when SetHandler fails because a handler is already registered for a
	// command type.
	ErrHandlerAlreadySet = errors.New("handler is already set")
	// ErrHandlerNotFound is when HandleCommand or HandleCommandEx fails because no handler is
	// registered for the given command type.
	ErrHandlerNotFound = errors.New("no handlers for command")
)

Functions

This section is empty.

Types

type CommandHandler

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

CommandHandler in the domain-eventing package is an eventing.CommandHandler that handles commands by routing them to the other eventing.CommandHandlers that are registered in it.

func NewCommandHandler

func NewCommandHandler() *CommandHandler

NewCommandHandler creates a CommandHandler with no eventing.CommandHandlers registered. Call SetHandler() to add handlers to it.

func (*CommandHandler) HandleCommand

func (h *CommandHandler) HandleCommand(ctx context.Context, cmd eventing.Command) error

HandleCommand handles a command with a handler capable of handling it.

func (*CommandHandler) HandleCommandEx

func (h *CommandHandler) HandleCommandEx(ctx context.Context, cmd eventing.Command) ([]common.Event, error)

HandleCommandEx handles a command with a handler capable of handling it.

func (*CommandHandler) SetHandler

func (h *CommandHandler) SetHandler(handler eventing.CommandHandler, cmdType common.CommandType) error

SetHandler adds/registers a handler for a specific command type. Only one handler can be set for a command type.

Jump to

Keyboard shortcuts

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