mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 12:45:04 +01:00
things
This commit is contained in:
parent
89820b06ca
commit
606438f301
14 changed files with 173 additions and 114 deletions
35
amqp_core/src/error.rs
Normal file
35
amqp_core/src/error.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ProtocolError {
|
||||
#[error("fatal error")]
|
||||
Fatal,
|
||||
#[error("{0}")]
|
||||
ConException(#[from] ConException),
|
||||
#[error("{0}")]
|
||||
ChannelException(#[from] ChannelException),
|
||||
#[error("Connection must be closed")]
|
||||
CloseNow,
|
||||
#[error("Graceful connection closing requested")]
|
||||
GracefulClose,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ConException {
|
||||
#[error("501 Frame error")]
|
||||
FrameError,
|
||||
#[error("503 Command invalid")]
|
||||
CommandInvalid,
|
||||
#[error("503 Syntax error | {0:?}")]
|
||||
/// A method was received but there was a syntax error. The string stores where it occurred.
|
||||
SyntaxError(Vec<String>),
|
||||
#[error("504 Channel error")]
|
||||
ChannelError,
|
||||
#[error("505 Unexpected Frame")]
|
||||
UnexpectedFrame,
|
||||
#[error("540 Not implemented")]
|
||||
NotImplemented,
|
||||
#[error("xxx Not decided yet")]
|
||||
Todo,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ChannelException {}
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
#![warn(rust_2018_idioms)]
|
||||
|
||||
pub mod error;
|
||||
pub mod message;
|
||||
pub mod methods;
|
||||
pub mod queue;
|
||||
|
||||
use crate::queue::Queue;
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashMap;
|
||||
use std::net::SocketAddr;
|
||||
|
|
@ -47,6 +50,7 @@ pub struct Connection {
|
|||
pub peer_addr: SocketAddr,
|
||||
pub global_data: GlobalData,
|
||||
pub channels: HashMap<u16, ChannelHandle>,
|
||||
pub exclusive_queues: Vec<Queue>,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
|
|
@ -60,6 +64,7 @@ impl Connection {
|
|||
peer_addr,
|
||||
global_data,
|
||||
channels: HashMap::new(),
|
||||
exclusive_queues: vec![],
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
|||
25
amqp_core/src/queue.rs
Normal file
25
amqp_core/src/queue.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use crate::message::Message;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub type Queue = Arc<RawQueue>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RawQueue {
|
||||
pub id: Uuid,
|
||||
pub name: String,
|
||||
pub messages: Mutex<Vec<Message>>, // use a concurrent linked list???
|
||||
pub durable: bool,
|
||||
/// Whether the queue will automatically be deleted when no consumers uses it anymore.
|
||||
/// The queue can always be manually deleted.
|
||||
/// If auto-delete is enabled, it keeps track of the consumer count.
|
||||
pub deletion: QueueDeletion,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum QueueDeletion {
|
||||
Auto(AtomicUsize),
|
||||
Manual,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue