Expand description
§liner_broker
liner_broker is a simple and fast redis based message serverless broker.
Data transfer via TCP.
§Examples
use liner_broker::Liner;
fn main() {
let mut client1 = Liner::new("client1", "topic_client1", "localhost:2255", "redis://localhost/");
let mut client2 = Liner::new("client2", "topic_client2", "localhost:2256", "redis://localhost/");
client1.run(Box::new(|_to: &str, _from: &str, _data: &[u8]|{
println!("receive_from {}", _from);
}));
client2.run(Box::new(|_to: &str, _from: &str, _data: &[u8]|{
println!("receive_from {}", _from);
}));
let array = [0; 100];
for _ in 0..10{
client1.send_to("topic_client2", array.as_slice(), true);
println!("send_to client2");
}
}
Modules§
Macros§
Structs§
- Client
- Liner
- Receiver
Seed Entry - One catalog row for
Store::seed_receivers(JSON shape matches the Creceivers_jsonarray). - UData
Enums§
Traits§
- Store
- Operations the broker needs from a key–value / queue style store.
Functions§
- lnr_
clear_ ⚠addresses_ of_ topic - Cleaning client addresses. Call only when the client is not running yet.
- lnr_
clear_ ⚠stored_ messages - Clearing messages that were not previously sent for some reason. Call only when the client is not running yet.
- lnr_
delete_ ⚠client - Deleting a client.
- lnr_
new_ ⚠client - Deprecated: use
lnr_new_client_redis. Same behavior aslnr_new_client_redis. - lnr_
new_ ⚠client_ redis - Create new client (Redis URL).
- lnr_
new_ ⚠client_ sqlite - Create new client (SQLite database file path).
- lnr_
refresh_ ⚠address_ topic - Refresh address of topic (actual for new clients)
- lnr_run⚠
- Launching a client to send messages and listen for incoming messages.
- lnr_
send_ ⚠all - Send message to other clients. Call only when the client is already running.
- lnr_
send_ ⚠to - Send message to other client. Call only when the client is already running.
- lnr_
subscribe ⚠ - Subscribe to the topic and receive messages from other clients.
- lnr_
unsubscribe ⚠ - Unsubscribe from the topic and do not receive messages from other clients.
- open_
store - open_
store_ mutex - Same backends as
open_store, shared across Client / Listener / Sender threads.