43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
// use chrono::DateTime;
|
|
use clap::Parser;
|
|
// use humantime::Duration;
|
|
use log::info;
|
|
use sysvmq::SysvMq;
|
|
|
|
/// Send a message to a message queue
|
|
#[derive(Debug, Parser)]
|
|
pub struct Send {
|
|
// /// Set a different priority, priority >= 0
|
|
// #[clap(short, long, default_value = "0")]
|
|
// priority: u32,
|
|
// /// Do not block
|
|
// #[clap(short, long)]
|
|
// non_blocking: bool,
|
|
// /// Timeout, example "5h 23min 42ms"
|
|
// #[clap(short = 'o', long, conflicts_with = "deadline")]
|
|
// timeout: Option<String>,
|
|
// /// Deadline until messages are sent (format: "%Y-%m-%d %H:%M:%S")
|
|
// #[clap(short, long, conflicts_with = "timeout")]
|
|
// deadline: Option<String>,
|
|
// /// Name of the queue
|
|
// #[clap(value_name = "QUEUE")]
|
|
// queue: String,
|
|
/// Key of of the queue to write to
|
|
#[clap(value_name = "Key")]
|
|
key: i32,
|
|
/// Message to be sent to the queue
|
|
#[clap(value_name = "MESSAGE")]
|
|
msg: String,
|
|
}
|
|
|
|
impl Send {
|
|
pub fn run(&self) -> Result<()> {
|
|
let mq = SysvMq::<String>::new();
|
|
|
|
mq.open(self.key)?.send(self.msg.as_bytes());
|
|
|
|
Ok(())
|
|
}
|
|
}
|