add exchanges to internal model

This commit is contained in:
nora 2022-03-20 17:52:41 +01:00
parent 504757b324
commit 58de7f1e2d
15 changed files with 169 additions and 40 deletions

View file

@ -7,7 +7,7 @@ use haesli_core::{
};
use tracing::{debug, error};
use crate::Result;
use crate::{routing, Result};
pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
debug!(?message, "Publishing message");
@ -22,9 +22,14 @@ pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
let global_data = global_data.lock();
let queue = global_data
.queues
.get(routing.routing_key.as_str())
let exchange = &message.routing.exchange;
let exchange = global_data
.exchanges
.get(exchange.as_str())
.ok_or(ChannelException::NotFound)?;
let queue = routing::route_message(exchange, &message.routing.routing_key)
.ok_or(ChannelException::NotFound)?;
queue