forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainer.rs
More file actions
38 lines (30 loc) · 1.11 KB
/
container.rs
File metadata and controls
38 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::sync::Arc;
use torrust_tracker_events::bus::SenderStatus;
use crate::event::bus::EventBus;
use crate::event::sender::Broadcaster;
use crate::event::{self};
use crate::statistics::repository::Repository;
use crate::{statistics, Registry};
pub struct SwarmCoordinationRegistryContainer {
pub swarms: Arc<Registry>,
pub event_bus: Arc<event::bus::EventBus>,
pub stats_event_sender: event::sender::Sender,
pub stats_repository: Arc<statistics::repository::Repository>,
}
impl SwarmCoordinationRegistryContainer {
#[must_use]
pub fn initialize(sender_status: SenderStatus) -> Self {
// // Swarm Coordination Registry Container stats
let broadcaster = Broadcaster::default();
let stats_repository = Arc::new(Repository::new());
let event_bus = Arc::new(EventBus::new(sender_status, broadcaster.clone()));
let stats_event_sender = event_bus.sender();
let swarms = Arc::new(Registry::new(stats_event_sender.clone()));
Self {
swarms,
event_bus,
stats_event_sender,
stats_repository,
}
}
}