improve everything

This commit is contained in:
nora 2022-03-19 19:01:31 +01:00
parent 543e39f129
commit dbc577abbc
10 changed files with 117 additions and 71 deletions

View file

@ -1,10 +1,10 @@
use std::sync::Arc;
use haesli_core::{
amqp_todo,
connection::Channel,
consumer::{Consumer, ConsumerId},
error::ChannelException,
haesli_todo,
methods::{BasicConsume, BasicConsumeOk, Method},
};
use tracing::info;
@ -23,7 +23,7 @@ pub fn consume(channel: Channel, basic_consume: BasicConsume) -> Result<Method>
} = basic_consume;
if no_wait || no_local || exclusive || no_ack {
haesli_todo!();
amqp_todo!();
}
let global_data = channel.global_data.clone();

View file

@ -2,7 +2,7 @@ mod consume;
mod publish;
mod queue;
use haesli_core::{connection::Channel, haesli_todo, message::Message, methods::Method};
use haesli_core::{amqp_todo, connection::Channel, message::Message, methods::Method};
use tracing::info;
use crate::Result;
@ -15,42 +15,42 @@ pub async fn handle_method(channel_handle: Channel, method: Method) -> Result<Me
info!(?method, "Handling method");
let response = match method {
Method::ExchangeDeclare(_) => haesli_todo!(),
Method::ExchangeDeclareOk(_) => haesli_todo!(),
Method::ExchangeDelete(_) => haesli_todo!(),
Method::ExchangeDeleteOk(_) => haesli_todo!(),
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)?,
Method::QueueDeclareOk { .. } => haesli_todo!(),
Method::QueueDeclareOk { .. } => amqp_todo!(),
Method::QueueBind(queue_bind) => queue::bind(channel_handle, queue_bind).await?,
Method::QueueBindOk(_) => haesli_todo!(),
Method::QueueUnbind { .. } => haesli_todo!(),
Method::QueueUnbindOk(_) => haesli_todo!(),
Method::QueuePurge { .. } => haesli_todo!(),
Method::QueuePurgeOk { .. } => haesli_todo!(),
Method::QueueDelete { .. } => haesli_todo!(),
Method::QueueDeleteOk { .. } => haesli_todo!(),
Method::BasicQos { .. } => haesli_todo!(),
Method::BasicQosOk(_) => haesli_todo!(),
Method::QueueBindOk(_) => amqp_todo!(),
Method::QueueUnbind { .. } => 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(consume) => consume::consume(channel_handle, consume)?,
Method::BasicConsumeOk { .. } => haesli_todo!(),
Method::BasicCancel { .. } => haesli_todo!(),
Method::BasicCancelOk { .. } => haesli_todo!(),
Method::BasicReturn { .. } => haesli_todo!(),
Method::BasicDeliver { .. } => haesli_todo!(),
Method::BasicGet { .. } => haesli_todo!(),
Method::BasicGetOk { .. } => haesli_todo!(),
Method::BasicGetEmpty { .. } => haesli_todo!(),
Method::BasicAck { .. } => haesli_todo!(),
Method::BasicReject { .. } => haesli_todo!(),
Method::BasicRecoverAsync { .. } => haesli_todo!(),
Method::BasicRecover { .. } => haesli_todo!(),
Method::BasicRecoverOk(_) => haesli_todo!(),
Method::BasicConsumeOk { .. } => amqp_todo!(),
Method::BasicCancel { .. } => amqp_todo!(),
Method::BasicCancelOk { .. } => amqp_todo!(),
Method::BasicReturn { .. } => amqp_todo!(),
Method::BasicDeliver { .. } => amqp_todo!(),
Method::BasicGet { .. } => amqp_todo!(),
Method::BasicGetOk { .. } => amqp_todo!(),
Method::BasicGetEmpty { .. } => amqp_todo!(),
Method::BasicAck { .. } => amqp_todo!(),
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(_) => haesli_todo!(),
| Method::TxRollbackOk(_) => amqp_todo!(),
Method::BasicPublish { .. } => {
unreachable!("Basic.Publish is handled somewhere else because it has a body")
}

View file

@ -1,7 +1,7 @@
use haesli_core::{
amqp_todo,
connection::Channel,
error::{ChannelException, ConException},
haesli_todo,
message::Message,
queue::QueueEvent,
};
@ -17,7 +17,7 @@ pub fn publish(channel_handle: Channel, message: Message) -> Result<()> {
let routing = &message.routing;
if !routing.exchange.is_empty() {
haesli_todo!();
amqp_todo!();
}
let global_data = global_data.lock();

View file

@ -1,8 +1,8 @@
use std::sync::{atomic::AtomicUsize, Arc};
use haesli_core::{
amqp_todo,
connection::Channel,
haesli_todo,
methods::{Method, QueueBind, QueueDeclare, QueueDeclareOk},
queue::{QueueDeletion, QueueId, QueueInner, QueueName},
GlobalData,
@ -24,16 +24,23 @@ pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method>
..
} = queue_declare;
// 2.1.4.1 - If no queue name is given, chose a name
let queue_name = if queue_name.is_empty() {
queue_name
} else {
format!("q_{}", haesli_core::random_uuid())
};
let queue_name = QueueName::new(queue_name.into());
if !arguments.is_empty() {
haesli_todo!();
amqp_todo!();
}
// todo: durable is technically spec-compliant, the spec doesn't really require it, but it's a todo
// not checked here because it's the default for amqplib which is annoying
// todo: implement durable, not checked here because it's the amqplib default
if passive || no_wait {
haesli_todo!();
amqp_todo!();
}
let global_data = channel.global_data.clone();
@ -79,7 +86,7 @@ pub fn declare(channel: Channel, queue_declare: QueueDeclare) -> Result<Method>
}
pub async fn bind(_channel_handle: Channel, _queue_bind: QueueBind) -> Result<Method> {
haesli_todo!();
amqp_todo!();
}
fn bind_queue(global_data: GlobalData, _exchange: (), routing_key: Arc<str>) -> Result<()> {