saluki_core/topology/
context.rs

1use std::sync::Arc;
2
3use tokio::runtime::Handle;
4
5use crate::accounting::MemoryLimiter;
6use crate::health::HealthRegistry;
7use crate::runtime::state::DataspaceRegistry;
8
9/// Topology context.
10#[derive(Clone)]
11pub struct TopologyContext {
12    topology_name: Arc<str>,
13    memory_limiter: MemoryLimiter,
14    health_registry: HealthRegistry,
15    global_thread_pool: Handle,
16    dataspace: DataspaceRegistry,
17}
18
19impl TopologyContext {
20    /// Creates a new `TopologyContext`.
21    pub fn new(
22        topology_name: Arc<str>, memory_limiter: MemoryLimiter, health_registry: HealthRegistry,
23        global_thread_pool: Handle, dataspace: DataspaceRegistry,
24    ) -> Self {
25        Self {
26            topology_name,
27            memory_limiter,
28            health_registry,
29            global_thread_pool,
30            dataspace,
31        }
32    }
33
34    /// Gets the name of the topology this context belongs to.
35    pub fn topology_name(&self) -> &str {
36        &self.topology_name
37    }
38
39    /// Gets a reference to the memory limiter.
40    pub fn memory_limiter(&self) -> &MemoryLimiter {
41        &self.memory_limiter
42    }
43
44    /// Gets a reference to the health registry.
45    pub fn health_registry(&self) -> &HealthRegistry {
46        &self.health_registry
47    }
48
49    /// Gets a reference to the global thread pool.
50    pub fn global_thread_pool(&self) -> &Handle {
51        &self.global_thread_pool
52    }
53
54    /// Gets a reference to the dataspace registry.
55    pub fn dataspace(&self) -> &DataspaceRegistry {
56        &self.dataspace
57    }
58}