more cleanup

This commit is contained in:
nora 2022-02-26 23:47:47 +01:00
parent 439696cf3f
commit 14ad4e1011
11 changed files with 1199 additions and 1048 deletions

View file

@ -1,17 +1,10 @@
use amqp_core::connection::ChannelHandle;
use amqp_core::error::ProtocolError;
use amqp_core::methods::{Bit, ConsumerTag, NoAck, NoLocal, NoWait, QueueName, Table};
use amqp_core::methods::BasicConsume;
#[allow(clippy::too_many_arguments)]
pub async fn consume(
_channel_handle: ChannelHandle,
_queue: QueueName,
_consumer_tag: ConsumerTag,
_no_local: NoLocal,
_no_ack: NoAck,
_exclusive: Bit,
_no_wait: NoWait,
_arguments: Table,
_basic_consume: BasicConsume,
) -> Result<(), ProtocolError> {
Ok(())
}

View file

@ -22,82 +22,23 @@ pub async fn handle_method(
info!(?method, "Handling method");
match method {
Method::ExchangeDeclare { .. } => amqp_todo!(),
Method::ExchangeDeclareOk => amqp_todo!(),
Method::ExchangeDelete { .. } => amqp_todo!(),
Method::ExchangeDeleteOk => amqp_todo!(),
Method::QueueDeclare {
queue,
passive,
durable,
exclusive,
auto_delete,
no_wait,
arguments,
..
} => {
queue::declare(
channel_handle,
queue,
passive,
durable,
exclusive,
auto_delete,
no_wait,
arguments,
)
.await
}
Method::ExchangeDeclare(_) => amqp_todo!(),
Method::ExchangeDeclareOk(_) => amqp_todo!(),
Method::ExchangeDelete(_) => amqp_todo!(),
Method::ExchangeDeleteOk(_) => amqp_todo!(),
Method::QueueDeclare(queue_declare) => queue::declare(channel_handle, queue_declare).await,
Method::QueueDeclareOk { .. } => amqp_todo!(),
Method::QueueBind {
queue,
exchange,
routing_key,
no_wait,
arguments,
..
} => {
queue::bind(
channel_handle,
queue,
exchange,
routing_key,
no_wait,
arguments,
)
.await
}
Method::QueueBindOk => amqp_todo!(),
Method::QueueBind(queue_bind) => queue::bind(channel_handle, queue_bind).await,
Method::QueueBindOk(_) => amqp_todo!(),
Method::QueueUnbind { .. } => amqp_todo!(),
Method::QueueUnbindOk => amqp_todo!(),
Method::QueueUnbindOk(_) => amqp_todo!(),
Method::QueuePurge { .. } => amqp_todo!(),
Method::QueuePurgeOk { .. } => amqp_todo!(),
Method::QueueDelete { .. } => amqp_todo!(),
Method::QueueDeleteOk { .. } => amqp_todo!(),
Method::BasicQos { .. } => amqp_todo!(),
Method::BasicQosOk => amqp_todo!(),
Method::BasicConsume {
queue,
consumer_tag,
no_local,
no_ack,
exclusive,
no_wait,
arguments,
..
} => {
consume::consume(
channel_handle,
queue,
consumer_tag,
no_local,
no_ack,
exclusive,
no_wait,
arguments,
)
.await
}
Method::BasicQosOk(_) => amqp_todo!(),
Method::BasicConsume(consume) => consume::consume(channel_handle, consume).await,
Method::BasicConsumeOk { .. } => amqp_todo!(),
Method::BasicCancel { .. } => amqp_todo!(),
Method::BasicCancelOk { .. } => amqp_todo!(),
@ -110,13 +51,13 @@ pub async fn handle_method(
Method::BasicReject { .. } => amqp_todo!(),
Method::BasicRecoverAsync { .. } => amqp_todo!(),
Method::BasicRecover { .. } => amqp_todo!(),
Method::BasicRecoverOk => amqp_todo!(),
Method::TxSelect
| Method::TxSelectOk
| Method::TxCommit
| Method::TxCommitOk
| Method::TxRollback
| Method::TxRollbackOk => amqp_todo!(),
Method::BasicRecoverOk(_) => amqp_todo!(),
Method::TxSelect(_)
| Method::TxSelectOk(_)
| Method::TxCommit(_)
| Method::TxCommitOk(_)
| Method::TxRollback(_)
| Method::TxRollbackOk(_) => amqp_todo!(),
Method::BasicPublish { .. } => {
unreachable!("Basic.Publish is handled somewhere else because it has a body")
}

View file

@ -1,23 +1,27 @@
use amqp_core::connection::ChannelHandle;
use amqp_core::error::{ConException, ProtocolError};
use amqp_core::methods::{Bit, ExchangeName, NoWait, QueueName, Shortstr, Table};
use amqp_core::methods::{QueueBind, QueueDeclare};
use amqp_core::queue::{QueueDeletion, QueueId, RawQueue};
use amqp_core::{amqp_todo, GlobalData};
use parking_lot::Mutex;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
#[allow(clippy::too_many_arguments)]
pub async fn declare(
channel_handle: ChannelHandle,
queue_name: QueueName,
passive: Bit,
durable: Bit,
exclusive: Bit,
auto_delete: Bit,
no_wait: NoWait,
arguments: Table,
queue_declare: QueueDeclare,
) -> Result<(), ProtocolError> {
let QueueDeclare {
queue: queue_name,
passive,
durable,
exclusive,
auto_delete,
no_wait,
arguments,
..
} = queue_declare;
if !arguments.is_empty() {
return Err(ConException::Todo.into());
}
@ -58,11 +62,7 @@ pub async fn declare(
pub async fn bind(
_channel_handle: ChannelHandle,
_queue: QueueName,
_exchange: ExchangeName,
_routing_key: Shortstr,
_no_wait: NoWait,
_arguments: Table,
_queue_bind: QueueBind,
) -> Result<(), ProtocolError> {
amqp_todo!();
}