Crates.io | memphis-rust-community |
lib.rs | memphis-rust-community |
version | 0.4.0 |
source | src |
created_at | 2023-06-26 23:27:52.988752 |
updated_at | 2023-10-12 11:01:12.659397 |
description | A Rust implementation of the Memphis Messaging Protocol |
homepage | https://github.com/turulix/memphis-rust-community |
repository | https://github.com/turulix/memphis-rust-community |
max_upload_size | |
id | 900807 |
size | 96,260 |
This is an unofficial client for Memphis, written in Rust.
Add the following to your Cargo.toml
file:
[dependencies]
memphis-rust-community = "0.4.0"
use memphis_rust_community::memphis_client::MemphisClient;
use memphis_rust_community::consumer::MemphisConsumerOptions;
use memphis_rust_community::station::MemphisStationsOptions;
#[tokio::main]
async fn main() {
let client = MemphisClient::new("localhost:6666", "root", "memphis", None).await.unwrap();
let station_options = MemphisStationsOptions::new("my-station");
let station = client.create_station(station_options).await.unwrap();
let consumer_options = MemphisConsumerOptions::new("my-consumer")
.with_generate_unique_suffix(true);
let consumer = station.create_consumer(consumer_options).await.unwrap();
let mut message_receiver = consumer.consume().await.unwrap();
tokio::spawn(async move {
loop {
let msg = message_receiver.recv().await;
// Do something with the message
break;
}
});
}
use memphis_rust_community::memphis_client::MemphisClient;
use memphis_rust_community::producer::MemphisProducerOptions;
use memphis_rust_community::station::MemphisStationsOptions;
#[tokio::main]
async fn main() {
let client = MemphisClient::new("localhost:6666", "root", "memphis", None).await.unwrap();
let station_options = MemphisStationsOptions::new("my-station");
let station = client.create_station(station_options).await.unwrap();
let producer_options = MemphisProducerOptions::new("my-producer")
.with_generate_unique_suffix(true);
let mut producer = station.create_producer(producer_options).await.unwrap();
let msg = ComposableMessage::new()
.with_payload("Hello World!")
.with_header("TestHeader", "TestValue");
producer.produce(msg).await.unwrap();
}