chore: move to once_cell from lazy_static
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::Database;
|
||||
use deadqueue::limited::Queue;
|
||||
use mongodb::bson::doc;
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use super::DelayedTask;
|
||||
|
||||
@@ -38,9 +39,7 @@ struct Task {
|
||||
event: AckEvent,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref Q: Queue<Data> = Queue::new(10_000);
|
||||
}
|
||||
static Q: Lazy<Queue<Data>> = Lazy::new(|| Queue::new(10_000));
|
||||
|
||||
/// Queue a new task for a worker
|
||||
pub async fn queue(channel: String, user: String, event: AckEvent) {
|
||||
|
||||
@@ -4,6 +4,7 @@ use crate::{models::channel::PartialChannel, Database};
|
||||
use deadqueue::limited::Queue;
|
||||
use mongodb::bson::doc;
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use super::DelayedTask;
|
||||
|
||||
@@ -26,9 +27,7 @@ struct Task {
|
||||
is_dm: bool,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref Q: Queue<Data> = Queue::new(10_000);
|
||||
}
|
||||
static Q: Lazy<Queue<Data>> = Lazy::new(|| Queue::new(10_000));
|
||||
|
||||
/// Queue a new task for a worker
|
||||
pub async fn queue(channel: String, id: String, is_dm: bool) {
|
||||
|
||||
@@ -9,6 +9,7 @@ use async_lock::Semaphore;
|
||||
use async_std::task::spawn;
|
||||
use deadqueue::limited::Queue;
|
||||
use std::sync::Arc;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Task information
|
||||
#[derive(Debug)]
|
||||
@@ -21,9 +22,8 @@ struct EmbedTask {
|
||||
content: String,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref Q: Queue<EmbedTask> = Queue::new(10_000);
|
||||
}
|
||||
static Q: Lazy<Queue<EmbedTask>> = Lazy::new(|| Queue::new(10_000));
|
||||
|
||||
|
||||
/// Queue a new task for a worker
|
||||
pub async fn queue(channel: String, id: String, content: String) {
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::util::variables::delta::VAPID_PRIVATE_KEY;
|
||||
|
||||
use authifier::Database;
|
||||
use deadqueue::limited::Queue;
|
||||
use once_cell::sync::Lazy;
|
||||
use web_push::{
|
||||
ContentEncoding, SubscriptionInfo, SubscriptionKeys, VapidSignatureBuilder, WebPushClient,
|
||||
WebPushMessageBuilder,
|
||||
@@ -17,9 +18,8 @@ struct PushTask {
|
||||
payload: String,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref Q: Queue<PushTask> = Queue::new(10_000);
|
||||
}
|
||||
static Q: Lazy<Queue<PushTask>> = Lazy::new(|| Queue::new(10_000));
|
||||
|
||||
|
||||
/// Queue a new task for a worker
|
||||
pub async fn queue(recipients: Vec<String>, payload: String) {
|
||||
|
||||
Reference in New Issue
Block a user