Simple queue

This commit is contained in:
eraden 2023-05-26 09:11:28 +02:00
parent ccf033eeed
commit 4a557a7de3
3 changed files with 5 additions and 12 deletions

View File

@ -5,7 +5,7 @@ pub enum Msg {
#[derive(Debug, serde::Deserialize, serde::Serialize)] #[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Message { pub struct Message {
pub index: usize, pub offset: usize,
pub payload: Msg, pub payload: Msg,
} }

View File

@ -1,5 +1,6 @@
use flumedb::*; use flumedb::*;
use gumdrop::Options; use gumdrop::Options;
use event_bus_adapter::*;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
enum Error {} enum Error {}
@ -15,16 +16,8 @@ struct Opts {
#[async_std::main] #[async_std::main]
async fn main() -> Result<(), Error> { async fn main() -> Result<(), Error> {
let path = { let opts: Opts = Options::parse_args_default_or_exit();
let args = std::env::args(); let path = opts.log_path;
let mut iter = args.into_iter();
iter
.next();
iter.next()
.expect("Log file path not found. Please privide path to log file")
};
eprintln!("File: {path}");
let mut log = OffsetLog::<u32>::from_file( let mut log = OffsetLog::<u32>::from_file(
std::fs::OpenOptions::new() std::fs::OpenOptions::new()
.append(true) .append(true)

View File

@ -17,7 +17,7 @@ impl MessageSend for MessageSender {
async fn send(&mut self, msg: Msg) { async fn send(&mut self, msg: Msg) {
match (Message { match (Message {
payload: msg, payload: msg,
index: 0, offset: 0,
}) })
.to_bytes() .to_bytes()
{ {