Skip to main content

Crate klieo_bus_nats

Crate klieo_bus_nats 

Source
Expand description

Production NATS JetStream + KV implementations of klieo-core’s bus traits (klieo_core::Pubsub, klieo_core::RequestReply, klieo_core::KvStore, klieo_core::JobQueue).

This is the differentiator vs other Rust agent frameworks: durable, leased, dedup’d, DLQ-routed inter-agent communication. Work does not get stuck.

§Quickstart

// After Plan #9 Task 7 lands:
//   use klieo_bus_nats::{NatsBus, NatsBusConfig};
//   let bus = NatsBus::connect(NatsBusConfig::default()).await?;

§Limitations

  • JetStream / KV must be enabled on the server. Run nats-server -js.
  • First-call latency. Streams + KV buckets are created idempotently on first publish/subscribe; that adds one round-trip per (subject pattern, bucket) tuple. Subsequent calls are cached.
  • Pull-consumer batch size = 1. JobQueue::claim pulls one message at a time; this matches the trait’s “claim next” shape. For higher throughput, run multiple workers.

Structs§

NatsAuth
Credentials and TLS toggle for a NATS connection.
NatsBus
Wired-together production bus. Build once, share across agents. The Arc<dyn ...> shape matches klieo_bus_memory::MemoryBus exactly, so callers can swap impls in config.
NatsBusConfig
Tunables for crate::NatsBus.
NatsJobQueue
JetStream-backed implementation of JobQueue.
NatsKv
JetStream KV-backed implementation of KvStore.
NatsPubsub
JetStream-backed implementation of Pubsub.
NatsRequestReply
RequestReply impl. Uses NATS core (not JetStream) because request/reply is inherently ephemeral — durable replies make no sense.