mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 12:45:04 +01:00
fix
This commit is contained in:
parent
4346db648f
commit
5d127eceee
8 changed files with 53 additions and 62 deletions
|
|
@ -9,7 +9,7 @@ use amqp_core::{
|
|||
use std::sync::Arc;
|
||||
use tracing::info;
|
||||
|
||||
pub fn consume(channel_handle: Channel, basic_consume: BasicConsume) -> Result<Method> {
|
||||
pub fn consume(channel: Channel, basic_consume: BasicConsume) -> Result<Method> {
|
||||
let BasicConsume {
|
||||
queue: queue_name,
|
||||
consumer_tag,
|
||||
|
|
@ -24,10 +24,7 @@ pub fn consume(channel_handle: Channel, basic_consume: BasicConsume) -> Result<M
|
|||
amqp_todo!();
|
||||
}
|
||||
|
||||
let global_data = {
|
||||
let channel = channel_handle.lock();
|
||||
channel.global_data.clone()
|
||||
};
|
||||
let global_data = channel.global_data.clone();
|
||||
|
||||
let consumer_tag = if consumer_tag.is_empty() {
|
||||
amqp_core::random_uuid().to_string()
|
||||
|
|
@ -40,7 +37,7 @@ pub fn consume(channel_handle: Channel, basic_consume: BasicConsume) -> Result<M
|
|||
let consumer = Consumer {
|
||||
id: ConsumerId::random(),
|
||||
tag: consumer_tag.clone(),
|
||||
channel: Arc::clone(&channel_handle),
|
||||
channel: Arc::clone(&channel),
|
||||
};
|
||||
|
||||
let queue = global_data
|
||||
|
|
|
|||
|
|
@ -4,17 +4,16 @@ mod queue;
|
|||
|
||||
use crate::Result;
|
||||
use amqp_core::{amqp_todo, connection::Channel, message::Message, methods::Method};
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, info};
|
||||
|
||||
pub async fn handle_basic_publish(channel_handle: Arc<Channel>, message: Message) {
|
||||
pub async fn handle_basic_publish(channel_handle: Channel, message: Message) {
|
||||
match publish::publish(channel_handle, message).await {
|
||||
Ok(()) => {}
|
||||
Err(err) => error!(%err, "publish error occurred"),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn handle_method(channel_handle: Arc<Channel>, method: Method) -> Result<Method> {
|
||||
pub async fn handle_method(channel_handle: Channel, method: Method) -> Result<Method> {
|
||||
info!(?method, "Handling method");
|
||||
|
||||
let response = match method {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ use amqp_core::{
|
|||
};
|
||||
use tracing::info;
|
||||
|
||||
pub async fn publish(channel_handle: Arc<Channel>, message: Message) -> Result<()> {
|
||||
pub async fn publish(channel_handle: Channel, message: Message) -> Result<()> {
|
||||
info!(?message, "Publishing message");
|
||||
|
||||
let global_data = channel_handle.lock().global_data.clone();
|
||||
let global_data = channel_handle.global_data.clone();
|
||||
|
||||
let routing = &message.routing;
|
||||
|
||||
|
|
@ -39,14 +39,11 @@ pub async fn publish(channel_handle: Arc<Channel>, message: Message) -> Result<(
|
|||
immediate: false,
|
||||
});
|
||||
|
||||
consumer
|
||||
.channel
|
||||
.lock()
|
||||
.queue_method(QueuedMethod::WithContent(
|
||||
method,
|
||||
message.header.clone(),
|
||||
message.content.clone(),
|
||||
));
|
||||
consumer.channel.queue_method(QueuedMethod::WithContent(
|
||||
method,
|
||||
message.header.clone(),
|
||||
message.content.clone(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use amqp_core::{
|
|||
use parking_lot::Mutex;
|
||||
use std::sync::{atomic::AtomicUsize, Arc};
|
||||
|
||||
pub fn declare(channel_handle: Channel, queue_declare: QueueDeclare) -> Result<Method> {
|
||||
pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method> {
|
||||
let QueueDeclare {
|
||||
queue: queue_name,
|
||||
passive,
|
||||
|
|
@ -34,7 +34,6 @@ pub fn declare(channel_handle: Channel, queue_declare: QueueDeclare) -> Result<M
|
|||
}
|
||||
|
||||
let global_data = {
|
||||
let channel = channel_handle.lock();
|
||||
let global_data = channel.global_data.clone();
|
||||
|
||||
let id = QueueId::random();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue