Files
mytheclipse/crates/corex-event/README.md
T
asepharyana d119821339 feat: add panic tracking and logging with PanicTracker
- Implemented PanicTracker to log panics using tracing within a dedicated span.
- Introduced PanicInfo struct to capture panic details.
- Added tests for panic catching and hook restoration.

feat: implement token-bucket rate limiter

- Created RateLimiter to manage token consumption with configurable rates and burst capacity.
- Added methods for acquiring tokens and checking available tokens.
- Included tests for rate limiting behavior and token availability.

feat: add automatic retry with exponential backoff

- Developed retry function to handle transient errors with configurable retry strategies.
- Introduced RetryConfig for customizing retry behavior and jitter.
- Added tests for various retry scenarios and error handling.

feat: implement graceful shutdown coordination

- Created ShutdownManager to manage shutdown signals and task completion.
- Introduced ShutdownSignal for tasks to observe shutdown requests.
- Added tests for shutdown request handling and task draining.

feat: add timeout functionality for async operations

- Implemented with_timeout function to enforce execution time limits on futures.
- Created Timeout struct for wrapping futures with a deadline.
- Added tests for timeout behavior and error mapping.
2026-08-28 21:46:18 +07:00

1.3 KiB

corex-event

A unified events & message bus abstraction so component-to-component (or service-to-service) communication isn't locked to one transport.

  • In-memory dispatcher (default) — tokio::sync::broadcast-backed pub/sub for communication inside a single process (monolith).
  • Distributed broker backends — RabbitMQ (amqp) and NATS (nats) behind the same EventBus trait, so swapping the backend doesn't change handler code.
  • Typed convenience — TypedEventBus layers JSON encoding on top.

Features

  • mem (default) — in-memory dispatcher.
  • amqp — RabbitMQ via lapin (pure Rust AMQP 0.9.1 client).
  • nats — NATS via async-nats.

Usage

use corex_event::{InMemoryEventBus, TypedEventBus};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct OrderCreated { id: u64 }

let bus = TypedEventBus::new(InMemoryEventBus::default());
let mut sub = bus.subscribe::<OrderCreated>("orders").await?;
bus.publish("orders", &OrderCreated { id: 42 }).await?;
let event = sub.recv().await?;

Swap InMemoryEventBus::default() for AmqpEventBus::connect(url, "exchange").await? or NatsEventBus::connect(url).await? to move to a distributed broker without touching handler code.