mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-14 19:55:03 +01:00
queue worker task
This commit is contained in:
parent
f860714b2b
commit
800ccae604
8 changed files with 111 additions and 36 deletions
|
|
@ -14,14 +14,24 @@ use crate::{
|
|||
};
|
||||
use connection::{ChannelId, ConnectionId};
|
||||
use parking_lot::Mutex;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{Debug, Formatter},
|
||||
sync::Arc,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct GlobalData {
|
||||
inner: Arc<Mutex<GlobalDataInner>>,
|
||||
}
|
||||
|
||||
impl Debug for GlobalData {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str("[global data]")
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for GlobalData {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ macro_rules! newtype_id {
|
|||
|
||||
impl ::std::fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
self.0.fmt(f)
|
||||
::std::fmt::Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,18 @@ use parking_lot::Mutex;
|
|||
use std::{
|
||||
borrow::Borrow,
|
||||
collections::HashMap,
|
||||
fmt::{Debug, Display, Formatter},
|
||||
sync::{atomic::AtomicUsize, Arc},
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
pub type Queue = Arc<RawQueue>;
|
||||
pub type Queue = Arc<QueueInner>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum QueueEvent {}
|
||||
|
||||
pub type QueueEventSender = mpsc::Sender<QueueEvent>;
|
||||
pub type QueueEventReceiver = mpsc::Receiver<QueueEvent>;
|
||||
|
||||
newtype_id!(pub QueueId);
|
||||
|
||||
|
|
@ -26,8 +34,14 @@ impl Borrow<str> for QueueName {
|
|||
}
|
||||
}
|
||||
|
||||
impl Display for QueueName {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RawQueue {
|
||||
pub struct QueueInner {
|
||||
pub id: QueueId,
|
||||
pub name: QueueName,
|
||||
pub messages: Mutex<Vec<Message>>, // use a concurrent linked list???
|
||||
|
|
@ -38,6 +52,7 @@ pub struct RawQueue {
|
|||
/// If auto-delete is enabled, it keeps track of the consumer count.
|
||||
pub deletion: QueueDeletion,
|
||||
pub consumers: Mutex<HashMap<ConsumerId, Consumer>>,
|
||||
pub event_send: QueueEventSender,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue