cqrs

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandEndpoint added in v1.2.5

func CommandEndpoint[C any](h CommandHandler[C]) endpoint.Endpoint[C, struct{}]

CommandEndpoint convert CommandHandler to Endpoint

func QueryEndpoint added in v1.2.5

func QueryEndpoint[Q any, R any](h QueryHandler[Q, R]) endpoint.Endpoint[Q, R]

QueryEndpoint convert QueryHandler to Endpoint

Types

type CommandHandler

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

CommandHandler is a command handler that to update data. Commands should be task-based, rather than data centric. Commands may be placed on a queue for asynchronous processing, rather than being processed synchronously.

type CommandHandlerFunc

type CommandHandlerFunc[C any] struct {
	// contains filtered or unexported fields
}

The CommandHandlerFunc type is an adapter to allow the use of ordinary functions as CommandHandler.

func (CommandHandlerFunc[C]) Handle

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

Handle calls f(ctx).

type NoopQuery added in v1.2.5

type NoopQuery[Q any, R any] struct{}

NoopQuery is an QueryHandler that does nothing and returns a nil error.

func (NoopQuery[Q, R]) Invoke added in v1.2.5

func (NoopQuery[Q, R]) Invoke(context.Context, Q) (R, error)

type QueryHandler

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

QueryHandler is a query handler that to queries to read data. Queries never modify the database. A query returns a DTO that does not encapsulate any domain knowledge.

type QueryHandlerFunc

type QueryHandlerFunc[Q any, R any] struct {
	// contains filtered or unexported fields
}

The QueryHandlerFunc type is an adapter to allow the use of ordinary functions as QueryHandler.

func (QueryHandlerFunc[Q, R]) Handle

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

Handle calls f(ctx).

Directories

Path Synopsis
cmd
cqrs command

Jump to

Keyboard shortcuts

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