cqrs

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 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.

func CommandHandlerFunc

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

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.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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