mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 20:55:03 +01:00
rename lol
This commit is contained in:
parent
c68cd04af7
commit
543e39f129
70 changed files with 283 additions and 266 deletions
39
haesli_messaging/src/methods/publish.rs
Normal file
39
haesli_messaging/src/methods/publish.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use haesli_core::{
|
||||
connection::Channel,
|
||||
error::{ChannelException, ConException},
|
||||
haesli_todo,
|
||||
message::Message,
|
||||
queue::QueueEvent,
|
||||
};
|
||||
use tracing::{debug, error};
|
||||
|
||||
use crate::Result;
|
||||
|
||||
pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
|
||||
debug!(?message, "Publishing message");
|
||||
|
||||
let global_data = channel_handle.global_data.clone();
|
||||
|
||||
let routing = &message.routing;
|
||||
|
||||
if !routing.exchange.is_empty() {
|
||||
haesli_todo!();
|
||||
}
|
||||
|
||||
let global_data = global_data.lock();
|
||||
|
||||
let queue = global_data
|
||||
.queues
|
||||
.get(routing.routing_key.as_str())
|
||||
.ok_or(ChannelException::NotFound)?;
|
||||
|
||||
queue
|
||||
.event_send
|
||||
.try_send(QueueEvent::PublishMessage(message))
|
||||
.map_err(|err| {
|
||||
error!(?err, "Failed to send message to queue event queue");
|
||||
ConException::InternalError
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue