cqrs

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandHandler

type CommandHandler[C any] interface {
	Handle(ctx context.Context, cmd C) error
}

func ChainCommandHandler

func ChainCommandHandler[C any](handler CommandHandler[C], middlewares ...CommandHandlerMiddleware[C]) CommandHandler[C]

ChainCommandHandler decorates the given CommandHandler with all middlewares.

type CommandHandlerFunc

type CommandHandlerFunc[C any] func(ctx context.Context, cmd C) error

The CommandHandlerFunc type is an adapter to allow the use of ordinary functions as CommandHandler. If f is a function with the appropriate signature, CommandHandlerFunc(f) is a CommandHandler that calls f.

func (CommandHandlerFunc[C]) Handle

func (f CommandHandlerFunc[C]) Handle(ctx context.Context, cmd C) error

Handle calls f(ctx).

type CommandHandlerMiddleware

type CommandHandlerMiddleware[C any] interface {
	// Decorate wraps the underlying Command, adding some functionality.
	Decorate(handler CommandHandler[C]) CommandHandler[C]
}

CommandHandlerMiddleware allows us to write something like decorators to CommandHandler. It can execute something before Handle or after.

type CommandHandlerMiddlewareFunc

type CommandHandlerMiddlewareFunc[C any] func(handler CommandHandler[C]) CommandHandler[C]

The CommandHandlerMiddlewareFunc type is an adapter to allow the use of ordinary functions as CommandHandlerMiddleware. If f is a function with the appropriate signature, CommandHandlerMiddlewareFunc(f) is a CommandHandlerMiddleware that calls f.

func (CommandHandlerMiddlewareFunc[C]) Decorate

func (f CommandHandlerMiddlewareFunc[C]) Decorate(handler CommandHandler[C]) CommandHandler[C]

Decorate call f(cmd).

type QueryHandler

type QueryHandler[Q any, R any] interface {
	Handle(ctx context.Context, q Q) (R, error)
}

func ChainQueryHandler

func ChainQueryHandler[Q any, R any](handler QueryHandler[Q, R], middlewares ...QueryHandlerMiddleware[Q, R]) QueryHandler[Q, R]

ChainQueryHandler decorates the given QueryHandler with all middlewares.

type QueryHandlerFunc

type QueryHandlerFunc[Q any, R any] func(ctx context.Context, q Q) (R, error)

The QueryHandlerFunc type is an adapter to allow the use of ordinary functions as QueryHandler. If f is a function with the appropriate signature, QueryHandlerFunc(f) is a QueryHandler that calls f.

func (QueryHandlerFunc[Q, R]) Handle

func (f QueryHandlerFunc[Q, R]) Handle(ctx context.Context, q Q) (R, error)

Handle calls f(ctx).

type QueryHandlerMiddleware

type QueryHandlerMiddleware[Q any, R any] interface {
	// Decorate wraps the underlying Command, adding some functionality.
	Decorate(QueryHandler[Q, R]) QueryHandler[Q, R]
}

QueryHandlerMiddleware allows us to write something like decorators to QueryHandler. It can execute something before Handle or after.

type QueryHandlerMiddlewareFunc

type QueryHandlerMiddlewareFunc[Q any, R any] func(QueryHandler[Q, R]) QueryHandler[Q, R]

The QueryHandlerMiddlewareFunc type is an adapter to allow the use of ordinary functions as QueryHandlerMiddleware. If f is a function with the appropriate signature, QueryHandlerMiddlewareFunc(f) is a QueryHandlerMiddleware that calls f.

func (QueryHandlerMiddlewareFunc[Q, R]) Decorate

func (f QueryHandlerMiddlewareFunc[Q, R]) Decorate(handler QueryHandler[Q, R]) QueryHandler[Q, R]

Decorate call f(cmd).

Jump to

Keyboard shortcuts

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