cqrs

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MIT Imports: 1 Imported by: 2

README

ose-micro/cqrs

A lightweight, extensible Go package for implementing the CQRS (Command Query Responsibility Segregation) pattern with message bus support.

Go Reference Go Report Card License

Overview

ose-micro/cqrs provides a simple yet powerful CQRS toolkit for Go microservices. It includes:

  • Generic CommandBus and QueryBus implementations.
  • Support for external buses like NATS.
  • Middleware support (logging, tracing, metrics, retries).

Built with generics to simplify development while keeping type safety and performance.

Features

  • ✅ Strongly typed command and query handlers using Go generics.
  • ✅ Middleware chaining for cross-cutting concerns.
  • ✅ Native support for NATS and easy extensibility for Kafka/Redis.
  • ✅ Pluggable message bus interface.
  • ✅ Clear separation of write and read models.

Installation

go get github.com/ose-micro/cqrs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	CommandName() string
	Validate() error
}

type CommandHandle

type CommandHandle[C Command, R any] interface {
	Handle(ctx context.Context, command C) (R, error)
}

type Event added in v0.0.7

type Event interface {
	EventName() string
}

type EventHandle added in v0.0.9

type EventHandle[E Event] interface {
	Handle(ctx context.Context, event E) error
}

type Query

type Query interface {
	QueryName() string
}

type QueryHandle

type QueryHandle[Q Query, R any] interface {
	Handle(ctx context.Context, query Q) (R, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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