cqrs

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 8 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 (
	ErrUnknownCommandType = errors.New("cqrs: unknown command type")
	ErrUnknownQueryType   = errors.New("cqrs: unknown query type")
)
View Source
var (
	ErrEventHandler = errors.New("cqrs: event handling failed")
)
View Source
var ErrUnimplementedHandler = errors.New("cqrs: unimplemented handler")

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp() *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

type Command

type Command interface{ Type() CommandType }

Command

type CommandBus

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

CommandBus

func NewCommandBus

func NewCommandBus() CommandBus

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, decoder Decoder) *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) 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)

type Decoder

type Decoder interface {
	DecodeCommand(CommandType, *http.Request) (Command, error)
	DecodeQuery(QueryType, *http.Request) (Query, error)
}

type Event

type Event interface {
	Type() EventType
	String() string
}

Event

type EventBus

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

EventBus

func NewEventBus

func NewEventBus() EventBus

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() QueryBus

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 struct {
	Data  any    `json:"data"`
	Error string `json:"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