CQRS Implementation #1
86
README.md
86
README.md
@ -1,3 +1,85 @@
|
||||
# stonecqrs
|
||||
# π₯ StoneCQRS - **10 billion% decoupled architecture!**
|
||||
|
||||
StoneCQRS - Ultimate CQRS/Event toolkit! β‘ Command/Query separation with event-driven superpowers. Perfect for complex domains & microservices. Saga-ready architecture baked in. Part of stone-utils ecosystem. 10 billion% more decoupled! π
|
||||
Ultimate CQRS/Event toolkit! β‘ Command/Query separation with event-driven superpowers. Perfect for complex domains & microservices. Saga-ready architecture baked in. Part of stone-utils ecosystem. 10 billion% more decoupled! π
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
|
||||
## π Why StoneCQRS?
|
||||
|
||||
- **CQRS/Event-Sourcing** with Senku-level precision
|
||||
- **Saga-ready** architecture out of the box
|
||||
- **100% decoupled** components (like good science should be)
|
||||
- **10 billion events/sec** handling capacity (theoretical)
|
||||
|
||||
## π₯ Installation
|
||||
|
||||
```bash
|
||||
go get gitstormr.dev/stone-utils/stonecqrs@latest
|
||||
```
|
||||
|
||||
## β‘ Basic Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitstormr.dev/stone-utils/stonecqrs"
|
||||
)
|
||||
|
||||
type CreateOrderCommand struct{ UserID string }
|
||||
type OrderCreatedEvent struct{ OrderID string }
|
||||
|
||||
type OrderHandler struct{}
|
||||
|
||||
func (h *OrderHandler) Handle(ctx context.Context, cmd stonecqrs.Command) ([]stonecqrs.Event, error) {
|
||||
return []stonecqrs.Event{OrderCreatedEvent{OrderID: "123"}}, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
dispatcher := stonecqrs.NewDispatcher()
|
||||
dispatcher.RegisterCommandHandler(CreateOrderCommand{}, &OrderHandler{})
|
||||
events, _ := dispatcher.DispatchCommand(ctx, CreateOrderCommand{UserID: "u-456"})
|
||||
// events = [OrderCreatedEvent]
|
||||
}
|
||||
```
|
||||
|
||||
## π¬ Core Patterns
|
||||
|
||||
### Command -> Event -> Reaction
|
||||
|
||||
```text
|
||||
[CreateOrderCommand]
|
||||
β
|
||||
[OrderCreatedEvent] β [PaymentHandler] β [InventoryHandler]
|
||||
```
|
||||
|
||||
### Saga ready flow
|
||||
|
||||
```go
|
||||
// 1. Execute command
|
||||
events, _ := dispatcher.DispatchCommand(ctx, cmd)
|
||||
|
||||
// 2. Automatic event processing
|
||||
// (Handlers trigger subsequent commands)
|
||||
|
||||
// 3. Compensation on failure
|
||||
// (Built-in rollback capabilities)
|
||||
```
|
||||
|
||||
## βοΈ Scientific Benchmarks
|
||||
|
||||
| METRIC | STANDARD LIB | STONECQRS |
|
||||
|---------------|---------------|-----------|
|
||||
| Decoupling | 30% | 10B% |
|
||||
| Scalability | 1x | βx |
|
||||
| Debuggability | β | ππ‘ |
|
||||
|
||||
**Join the Scientific Revolution!**
|
||||
|
||||
> "This isn't just CQRS - it's revolutionizing software patterns like we revived civilization!" - Senku Ishigami
|
||||
|
||||
Kingdom of Science Approved
|
||||
|
||||
(Now with 100% more Chrome screaming "SO BADASS!")
|
Loadingβ¦
x
Reference in New Issue
Block a user