11 releases

Uses new Rust 2024

4.0.0-canary.11 Mar 18, 2026
4.0.0-canary.7 Mar 17, 2026
3.0.0-canary.688 Aug 28, 2025
0.1.6 Jul 24, 2025
0.1.2 Dec 3, 2024

#669 in Asynchronous

31 downloads per month
Used in 5 crates (2 directly)

AGPL-3.0-or-later

535KB
11K SLoC

Myko RS - Event-Sourcing CQRS Framework

myko-rs is an actor-based event-sourcing framework for building real-time, distributed systems with strong consistency guarantees.

Core Concepts

Concept Description
Item Base entity with typed id
Event Immutable record of state change: SET (create/update) or DEL (delete)
Query Request for live data stream, returns reactive Observable<T[]>
Report Computed/derived data request, returns Observable<T>
Command Intent to mutate state, returns result of operation
Saga Stateful stream processor that reacts to events and emits commands

Architecture

┌──────────────────────────────────────────────────────────────────────────┐
│                             CellServer                                   │
│                                                                          │
│  WebSocket ──► WsHandler ──► CellServerCtx ──► StoreRegistry             │
│      │              │             │                   │                  │
│      │              │             │             CellMap<id, item>        │
│      │              ▼             │                   │                  │
│      │        KafkaProducer       │                   ▼                  │
│      │              │             │         Query/Report cells           │
│      │              ▼             │                   │                  │
│      │           Kafka ◄─────────────── KafkaConsumer                    │
│      │                                                                   │
│      ◄────────────────────── (subscription updates)                      │
└──────────────────────────────────────────────────────────────────────────┘

Quick Start

Define an entity using the #[myko_item] attribute macro:

use myko_rs::prelude::*;

#[myko_item]
pub struct Target {
    pub name: String,
    pub category: Option<String>,
    // id is added automatically
}

The macro auto-generates:

  • GetAllTargets, GetTargetsByIds, GetTargetsByQuery queries
  • CountAllTargets, CountTargets, GetTargetById reports
  • DeleteTarget, DeleteTargets commands
  • PartialTarget struct for partial matching
  • Registration with the inventory system

Module Guide

Module Purpose
client WebSocket client for connecting to Myko servers
core Core types: command, query, report, saga, item, relationship
wire Wire protocol types: MykoMessage, MEvent, responses, errors
server CellServer and server context
store Entity store and registry

Performance

Myko-rs is optimized for high-throughput, low-latency scenarios:

  • Hyphae cells: Reactive queries and reports using the hyphae cell library
  • Lock-free stores: CellMap for concurrent entity access
  • MessagePack serialization: Binary format for efficient WebSocket communication
  • Optional Kafka: Run in-memory for development, add Kafka for production persistence

See libs/myko/rs/OPTIMIZATION.md for detailed performance guidelines.

Dependencies

~7–27MB
~332K SLoC