cqrs

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cqrs

Golang CQRS Framework

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventHandler         = errors.New("cqrs: failed to handle event")
	ErrUnknownCommandType   = errors.New("cqrs: unknown command type")
	ErrUnknownQueryType     = errors.New("cqrs: unknown query type")
	ErrUnimplementedHandler = errors.New("cqrs: unimplemented handler")
	ErrPanicRecovered       = errors.New("cqrs: panic recovered")
)

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp(logger *slog.Logger) *App

func (*App) CommandHandler

func (app *App) CommandHandler() CommandHandler

func (*App) EventHandler

func (app *App) EventHandler() EventHandler

func (*App) HandleCommand

func (app *App) HandleCommand(t CommandType, f CommandHandlerFunc)

func (*App) HandleEvent

func (app *App) HandleEvent(t EventType, f EventHandlerFunc)

func (*App) HandleQuery

func (app *App) HandleQuery(t QueryType, f QueryHandlerFunc)

func (*App) QueryHandler

func (app *App) QueryHandler() QueryHandler

func (*App) WithCommandBus added in v1.1.1

func (app *App) WithCommandBus(cb CommandBus) *App

func (*App) WithEventBus added in v1.1.1

func (app *App) WithEventBus(eb EventBus) *App

func (*App) WithQueryBus added in v1.1.1

func (app *App) WithQueryBus(qb QueryBus) *App

type Codec added in v1.1.1

type Codec interface {
	Decoder
	Encoder
}

type Command

type Command interface{ Type() CommandType }

Command

type CommandBus

type CommandBus interface {
	CommandHandler
	HandleFunc(CommandType, CommandHandlerFunc)
}

CommandBus

func NewCommandBus

func NewCommandBus(logger *slog.Logger) CommandBus

type CommandDecoder added in v1.1.1

type CommandDecoder interface {
	DecodeCommand(CommandType, []byte) (Command, error)
}

type CommandHandler

type CommandHandler interface {
	Types() []CommandType
	Handle(context.Context, Command) ([]Event, error)
}

CommandHandler

type CommandHandlerFunc

type CommandHandlerFunc func(context.Context, Command) ([]Event, error)

CommandHandlerFunc

type CommandType

type CommandType string

CommandType

func (CommandType) String

func (ct CommandType) String() string

type Controller

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

func NewController

func NewController(logger *slog.Logger, app *App, codec Codec) *Controller

func (*Controller) Close

func (c *Controller) Close()

func (*Controller) Commands

func (c *Controller) Commands(w http.ResponseWriter, r *http.Request)

func (*Controller) Events

func (c *Controller) Events(w http.ResponseWriter, r *http.Request)

func (*Controller) Handler

func (c *Controller) Handler() http.Handler

func (*Controller) Queries

func (c *Controller) Queries(w http.ResponseWriter, r *http.Request)

func (*Controller) Queue added in v1.1.1

func (c *Controller) Queue() int

func (*Controller) ServeCommands

func (c *Controller) ServeCommands(w http.ResponseWriter, r *http.Request)

func (*Controller) ServeEvents

func (c *Controller) ServeEvents(w http.ResponseWriter, r *http.Request)

func (*Controller) ServeQueries

func (c *Controller) ServeQueries(w http.ResponseWriter, r *http.Request)

func (*Controller) Streams added in v1.1.1

func (c *Controller) Streams() int

func (*Controller) WithConfig added in v1.1.1

func (c *Controller) WithConfig(config ControllerConfig) *Controller

type ControllerConfig added in v1.1.1

type ControllerConfig struct {
	MaxEventBuffer     int
	MaxConcurrentTasks int
}

func DefaultControllerConfig added in v1.1.1

func DefaultControllerConfig() ControllerConfig

type Decoder

type Decoder interface {
	CommandDecoder
	QueryDecoder
}

type Encoder added in v1.1.1

type Encoder interface {
	EventEncoder
	ResultEncoder
}

type Event

type Event interface {
	Type() EventType
}

Event

type EventBus

type EventBus interface {
	EventHandler
	HandleFunc(EventType, EventHandlerFunc)
}

EventBus

func NewEventBus

func NewEventBus(logger *slog.Logger) EventBus

type EventEncoder added in v1.1.1

type EventEncoder interface {
	EncodeEvent(Event) ([]byte, error)
}

type EventHandler

type EventHandler interface {
	Types() []EventType
	Handle(context.Context, Event) error
}

EventHandler

type EventHandlerFunc

type EventHandlerFunc func(context.Context, Event) error

EventHandlerFunc

type EventType

type EventType string

EventType

func (EventType) String

func (et EventType) String() string

type Query

type Query interface{ Type() QueryType }

Query

type QueryBus

type QueryBus interface {
	QueryHandler
	HandleFunc(QueryType, QueryHandlerFunc)
}

QueryBus

func NewQueryBus

func NewQueryBus(logger *slog.Logger) QueryBus

type QueryDecoder added in v1.1.1

type QueryDecoder interface {
	DecodeQuery(QueryType, []byte) (Query, error)
}

type QueryHandler

type QueryHandler interface {
	Types() []QueryType
	Handle(context.Context, Query) (Result, error)
}

QueryHandler

type QueryHandlerFunc

type QueryHandlerFunc func(context.Context, Query) (Result, error)

QueryHandlerFunc

type QueryType

type QueryType string

QueryType

func (QueryType) String

func (qt QueryType) String() string

type Result

type Result interface {
	Data() any
	Error() error
}

type ResultEncoder added in v1.1.1

type ResultEncoder interface {
	EncodeResult(Result) ([]byte, error)
}

type TraceID

type TraceID string

func Trace

func Trace(ctx context.Context) TraceID

func (TraceID) String

func (tid TraceID) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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