Skip to content

fermi-ad/rust-pubsub-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-pubsub-lib

rust-pubsub-lib provides a shared abstraction for publishing to, snapshotting from, and subscribing to broker-backed topics from Rust applications. It hides backend-specific connection details behind a small set of async traits so application code can stay focused on message handling instead of transport setup.

Interface

The primary abstractions provided by this library are the Publisher, Snapshot, and Subscriber traits.

  • Publisher asynchronously sends a message to a configured topic.
  • Snapshot reads the currently available messages for a topic in one operation.
  • Subscriber yields a stream of messages as they arrive.
  • Message describes the message shape used across all backends.

The library also provides concrete message helpers:

  • ByteMessage for raw byte payloads.
  • StringMessage for UTF-8-oriented payloads, using lossy decoding when byte input is not valid UTF-8.

Feature selection

Select one or more crate features depending on the broker backend your application uses.

Required environment variables

The following environment variables are required for Kafka-backed behavior:

Redis-backed implementations do not currently require a crate-specific environment variable, but they do require a valid Redis connection URI to be passed to Publisher::new(), Snapshot::get(), or Subscriber::new().

Documentation

Generate the crate documentation locally with cargo doc --all-features and open the output from target/doc/. The most important API entry points are documented in src/lib.rs, with backend-specific details under src/kafka_impl/mod.rs and src/redis_impls/mod.rs.

Development

The following packages must be present on the host machine when building this library:

  • cmake
  • libcurl4-openssl-dev
  • libsasl2-dev
  • zlib

The configured Dev Container in .devcontainer/ has the necessary tools to build without additional installation.

About

A Rust library for publisher-subscriber interactions. Used to hide the implementation of whatever pub-sub service is in use (e.g., Kafka).

Resources

License

Code of conduct

Stars

2 stars

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages