mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-15 20:25:02 +01:00
more queue stuff
This commit is contained in:
parent
14ad4e1011
commit
4643483d70
15 changed files with 126 additions and 42 deletions
|
|
@ -25,8 +25,8 @@ pub enum ConException {
|
|||
ChannelError,
|
||||
#[error("505 Unexpected Frame")]
|
||||
UnexpectedFrame,
|
||||
#[error("540 Not implemented")]
|
||||
NotImplemented,
|
||||
#[error("540 Not implemented. '{0}'")]
|
||||
NotImplemented(&'static str),
|
||||
#[error("xxx Not decided yet")]
|
||||
Todo,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub mod methods;
|
|||
pub mod queue;
|
||||
|
||||
use crate::connection::{ChannelHandle, ConnectionHandle};
|
||||
use crate::queue::{Queue, QueueId};
|
||||
use crate::queue::{Queue, QueueName};
|
||||
use connection::{ChannelId, ConnectionId};
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -44,7 +44,7 @@ impl GlobalData {
|
|||
pub struct GlobalDataInner {
|
||||
pub connections: HashMap<ConnectionId, ConnectionHandle>,
|
||||
pub channels: HashMap<ChannelId, ChannelHandle>,
|
||||
pub queues: HashMap<QueueId, Queue>,
|
||||
pub queues: HashMap<QueueName, Queue>,
|
||||
/// Todo: This is just for testing and will be removed later!
|
||||
pub default_exchange: HashMap<String, Queue>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,12 +48,23 @@ macro_rules! newtype {
|
|||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::convert::From<T> for $name
|
||||
where
|
||||
$ty: From<T>,
|
||||
{
|
||||
fn from(other: T) -> Self {
|
||||
Self(other.into())
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! amqp_todo {
|
||||
() => {
|
||||
return Err(::amqp_core::error::ConException::NotImplemented.into())
|
||||
return Err(
|
||||
::amqp_core::error::ConException::NotImplemented(concat!(file!(), ":", line!())).into(),
|
||||
)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::message::Message;
|
||||
use crate::{newtype_id, ChannelId};
|
||||
use crate::{newtype, newtype_id, ChannelId};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -8,10 +8,16 @@ pub type Queue = Arc<RawQueue>;
|
|||
|
||||
newtype_id!(pub QueueId);
|
||||
|
||||
newtype!(
|
||||
/// The name of a queue. A newtype wrapper around `Arc<str>`, which guarantees cheap clones.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub QueueName: Arc<str>
|
||||
);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RawQueue {
|
||||
pub id: QueueId,
|
||||
pub name: String,
|
||||
pub name: QueueName,
|
||||
pub messages: Mutex<Vec<Message>>, // use a concurrent linked list???
|
||||
pub durable: bool,
|
||||
pub exclusive: Option<ChannelId>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue