Skip to main content

Crate liner_broker

Crate liner_broker 

Source
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§

redis

Macros§

print_debug
print_error

Structs§

Client
Liner
ReceiverSeedEntry
One catalog row for Store::seed_receivers (JSON shape matches the C receivers_json array).
UData

Enums§

StoreBackend

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 as lnr_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.