cqrs

package
v0.0.0-...-de2e133 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandBus

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

CommandBus is the struct to represent the command bus, can only use commandHandlers

func NewCommandBus

func NewCommandBus() *CommandBus

NewCommandBus is used to instanciate a new command bus

func (*CommandBus) Dispatch

func (b *CommandBus) Dispatch(command CommandMessage) (interface{}, error)

Dispatch a command in the command bus, the handler corresponding to the command will be executed

func (*CommandBus) RegisterHandler

func (b *CommandBus) RegisterHandler(handler CommandHandler, command interface{}) error

RegisterHandler is used to add a handler to your command bus, it associates your handler with the command type provided

type CommandDescriptor

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

CommandDescriptor is the struct used to represent our commands

func NewCommandMessage

func NewCommandMessage(command interface{}) *CommandDescriptor

NewCommandMessage takes an interface and returns a commandDescriptor that can be passed to the bus

func (*CommandDescriptor) CommandType

func (c *CommandDescriptor) CommandType() string

CommandType returns the command type

func (*CommandDescriptor) Payload

func (c *CommandDescriptor) Payload() interface{}

Payload returns the actual command payload of the message.

type CommandHandler

type CommandHandler interface {
	Handle(CommandMessage) (interface{}, error)
}

CommandHandler is the interface to give to the bus in order to register a command&handler

type CommandMessage

type CommandMessage interface {
	CommandType() string
	Payload() interface{}
}

CommandMessage is the interface for all messages conveying in the command bus

type QueryBus

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

QueryBus is the struct to represent the command bus, can only use commandHandlers

func NewQueryBus

func NewQueryBus() *QueryBus

NewQueryBus is used to instanciate a new command bus

func (*QueryBus) Dispatch

func (b *QueryBus) Dispatch(query QueryMessage) (interface{}, error)

Dispatch a command in the command bus, the handler corresponding to the command will be executed

func (*QueryBus) RegisterHandler

func (b *QueryBus) RegisterHandler(handler QueryHandler, query interface{}) error

RegisterHandler is used to add a handler to your command bus, it associates your handler with the command type provided

type QueryDescriptor

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

QueryDescriptor is the struct used to represent our commands

func NewQueryMessage

func NewQueryMessage(query interface{}) *QueryDescriptor

NewQueryMessage takes an interface and returns a commandDescriptor that can be passed to the bus

func (*QueryDescriptor) Payload

func (c *QueryDescriptor) Payload() interface{}

Payload returns the actual command payload of the message.

func (*QueryDescriptor) QueryType

func (c *QueryDescriptor) QueryType() string

QueryType returns the command type

type QueryHandler

type QueryHandler interface {
	Handle(QueryMessage) (interface{}, error)
}

QueryHandler is the interface to give to the bus in order to register a query&handler

type QueryMessage

type QueryMessage interface {
	Payload() interface{}
	QueryType() string
}

QueryMessage is the interface for all messages conveying in the command bus

Jump to

Keyboard shortcuts

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