mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-11 12:53:00 +02:00
de-global services for services
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
992c0a1e58
commit
010e4ee35a
85 changed files with 2480 additions and 1887 deletions
|
@ -5,7 +5,7 @@ use database::{Database, Map};
|
|||
use ruma::{ServerName, UserId};
|
||||
|
||||
use super::{Destination, SendingEvent};
|
||||
use crate::services;
|
||||
use crate::{globals, Dep};
|
||||
|
||||
type OutgoingSendingIter<'a> = Box<dyn Iterator<Item = Result<(Vec<u8>, Destination, SendingEvent)>> + 'a>;
|
||||
type SendingEventIter<'a> = Box<dyn Iterator<Item = Result<(Vec<u8>, SendingEvent)>> + 'a>;
|
||||
|
@ -15,15 +15,24 @@ pub struct Data {
|
|||
servernameevent_data: Arc<Map>,
|
||||
servername_educount: Arc<Map>,
|
||||
pub(super) db: Arc<Database>,
|
||||
services: Services,
|
||||
}
|
||||
|
||||
struct Services {
|
||||
globals: Dep<globals::Service>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
pub(super) fn new(db: Arc<Database>) -> Self {
|
||||
pub(super) fn new(args: &crate::Args<'_>) -> Self {
|
||||
let db = &args.db;
|
||||
Self {
|
||||
servercurrentevent_data: db["servercurrentevent_data"].clone(),
|
||||
servernameevent_data: db["servernameevent_data"].clone(),
|
||||
servername_educount: db["servername_educount"].clone(),
|
||||
db,
|
||||
db: args.db.clone(),
|
||||
services: Services {
|
||||
globals: args.depend::<globals::Service>("globals"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +87,7 @@ impl Data {
|
|||
if let SendingEvent::Pdu(value) = &event {
|
||||
key.extend_from_slice(value);
|
||||
} else {
|
||||
key.extend_from_slice(&services().globals.next_count()?.to_be_bytes());
|
||||
key.extend_from_slice(&self.services.globals.next_count()?.to_be_bytes());
|
||||
}
|
||||
let value = if let SendingEvent::Edu(value) = &event {
|
||||
&**value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue