This subdirectory contains the library code for LucidMQ. LucidMQ is a library that implements event streaming directly into your application in a brokerless fashion. There is no external processes running, just import LucidMQ and start passing message though to your different applications that are also using LucidMQ.
There are 4 main components that LucidMQ exposes:
LucidMQ: Handles all the metadata of the topics and initialization of consumers and producers.
Producer: Given a topic, the producer will write persistent messages to that topic.
Consumer: Given a topic, the consumer will read messages from that topic. It will know it's last read offset which is persisted. ALl consumers start at the oldest offset.
Message: Similar to kafka all messages utilize a key, value and timestamp format.
```rust use lucidmq::{LucidMQ, Message};
// Create our lucidmq instance let mut lucidmq = LucidMQ::new("basedirectory".tostring(), 1000, 5000);
// Let's produce message to our message queue let mut producer = lucidmq.newproducer("topic1".tostring()); // Create a message that you want to send. // Every message has a key, value and timestamp. let key = format!("key{}", 1); let value = format!("value{}", 1); let message = Message::new(key.asbytes(), value.asbytes(), None); producer.produce_message(message);
// Let's create a consumer to consumer our messages let mut consumer = lucidmq.newconsumer("topic1".tostring()); // Get all the messages for that polling period let records = consumer.poll(1000); // Print out all of the messages recieved. for record in records { println!("{}", str::fromutf8(&record.key).unwrap()); println!("{}", str::fromutf8(&record.value).unwrap()); println!("{}", record.timestamp); } ```