All checks were successful
Go CI/CD / go-ci (push) Successful in 36s
Introduces the 'Singularity' implementation, a CQRS Bus that supports commands, queries, and events, along with middleware extensibility. Includes comprehensive tests, modular files for commands, queries, and events, as well as CI/CD workflows.
22 lines
412 B
Go
22 lines
412 B
Go
package cqrs
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type Command interface{}
|
|
|
|
type CommandMiddleware func(CommandHandler) CommandHandler
|
|
|
|
type CommandHandlerFunc func(ctx context.Context, cmd Command) ([]Event, error)
|
|
|
|
func (f CommandHandlerFunc) Handle(ctx context.Context, cmd Command) (
|
|
[]Event, error,
|
|
) {
|
|
return f(ctx, cmd)
|
|
}
|
|
|
|
type CommandHandler interface {
|
|
Handle(ctx context.Context, cmd Command) ([]Event, error)
|
|
}
|