queue declare

This commit is contained in:
nora 2022-02-26 21:55:17 +01:00
parent 606438f301
commit 8532d454c3
13 changed files with 255 additions and 71 deletions

View file

@ -353,7 +353,7 @@ impl Connection {
} = method
{
let message = RawMessage {
id: Uuid::from_bytes(rand::random()),
id: amqp_core::gen_uuid(),
properties: header.property_fields,
routing: RoutingInformation {
exchange,
@ -380,7 +380,7 @@ impl Connection {
}
async fn channel_open(&mut self, channel_id: ChannelId) -> Result<()> {
let id = Uuid::from_bytes(rand::random());
let id = amqp_core::gen_uuid();
let channel_handle = amqp_core::Channel::new_handle(
id,
channel_id.num(),

View file

@ -15,7 +15,6 @@ use amqp_core::GlobalData;
use anyhow::Result;
use tokio::net;
use tracing::{info, info_span, Instrument};
use uuid::Uuid;
pub async fn do_thing_i_guess(global_data: GlobalData) -> Result<()> {
info!("Binding TCP listener...");
@ -25,7 +24,7 @@ pub async fn do_thing_i_guess(global_data: GlobalData) -> Result<()> {
loop {
let (stream, peer_addr) = listener.accept().await?;
let id = Uuid::from_bytes(rand::random());
let id = amqp_core::gen_uuid();
info!(local_addr = ?stream.local_addr(), %id, "Accepted new connection");
let span = info_span!("client-connection", %id);

View file

@ -42,8 +42,8 @@ pub fn fail_err<S: Into<String>>(msg: S) -> impl FnOnce(Err<TransError>) -> Err<
Err::Failure(ConException::SyntaxError(stack).into())
}
}
pub fn err_other<E, S: Into<String>>(msg: S) -> impl FnOnce(E) -> Err<TransError> {
move |_| Err::Error(ConException::SyntaxError(vec![msg.into()]).into())
pub fn other_fail<E, S: Into<String>>(msg: S) -> impl FnOnce(E) -> Err<TransError> {
move |_| Err::Failure(ConException::SyntaxError(vec![msg.into()]).into())
}
#[macro_export]
@ -105,7 +105,7 @@ pub fn bit(input: &[u8], amount: usize) -> IResult<'_, Vec<Bit>> {
pub fn shortstr(input: &[u8]) -> IResult<'_, Shortstr> {
let (input, len) = u8(input)?;
let (input, str_data) = take(usize::from(len))(input)?;
let data = String::from_utf8(str_data.into()).map_err(err_other("shortstr"))?;
let data = String::from_utf8(str_data.into()).map_err(other_fail("shortstr"))?;
Ok((input, data))
}

View file

@ -16,9 +16,9 @@ pub fn parse_sasl_plain_response(response: &[u8]) -> Result<PlainUser> {
.split(|&n| n == 0)
.map(|bytes| String::from_utf8(bytes.into()).map_err(|_| ConException::Todo));
let authorization_identity = parts.next().ok_or_else(|| ConException::Todo)??;
let authentication_identity = parts.next().ok_or_else(|| ConException::Todo)??;
let password = parts.next().ok_or_else(|| ConException::Todo)??;
let authorization_identity = parts.next().ok_or(ConException::Todo)??;
let authentication_identity = parts.next().ok_or(ConException::Todo)??;
let password = parts.next().ok_or(ConException::Todo)??;
Ok(PlainUser {
authorization_identity,