Skip to main content

Crate pulses

Crate pulses 

Source
Expand description

§Pulses

A robust, high-performance background job processing library for Rust.

Pulses consumes messages from a pluggable Broker (a Redis Streams backend ships behind the redis feature), routes each message to the Handlers that subscribe to its stream, and runs those handlers concurrently on the ambient multi-threaded Tokio runtime.

§Highlights

  • Type-safe handlers — register handlers at compile time; their streams are unioned automatically into the broker subscription, so there is no stream list to keep in sync by hand.
  • Real delivery semanticsOutcome::Retry honors its delay and is bounded by AppConfig::handler_max_attempts; exhausted or Outcome::DeadLetter messages are written to a durable dead-letter stream before being acknowledged.
  • Bounded concurrency & back-pressure — each handler runs up to a configurable number of in-flight messages; a saturated handler applies back-pressure to the reader.
  • Graceful shutdown — on cancellation the runtime stops accepting new work and drains in-flight handler invocations before returning.
  • Reliability — failed acknowledgements are retried, and pending messages abandoned by a crashed consumer are reclaimed.

See App for a complete usage example.

§Runtime

Pulses spawns its actors with tokio::spawn, so run it inside a multi-threaded runtime (the default #[tokio::main]) to process handlers in parallel across cores.

Re-exports§

pub use core::Broker;
pub use core::Context;
pub use core::Envelope;
pub use core::Handler;
pub use core::HandlerError;
pub use core::Outcome;
pub use core::Subscription;
pub use app::App;
pub use config::AppConfig;
pub use config::BackoffConfig;
pub use config::ConfigError;
pub use error::AppError;

Modules§

app
The App builder and runtime entry point.
broker
Broker backends.
config
Runtime configuration and validation.
core
Backend-agnostic core abstractions and value types.
error
Top-level error type returned by App::run.