saluki_core/components/destinations/
context.rs1use memory_accounting::ComponentRegistry;
2use saluki_health::Health;
3
4use crate::{
5 components::ComponentContext,
6 topology::{EventsConsumer, TopologyContext},
7};
8
9pub struct DestinationContext {
11 topology_context: TopologyContext,
12 component_context: ComponentContext,
13 component_registry: ComponentRegistry,
14 health_handle: Option<Health>,
15 consumer: EventsConsumer,
16}
17
18impl DestinationContext {
19 pub fn new(
21 topology_context: &TopologyContext, component_context: &ComponentContext,
22 component_registry: ComponentRegistry, health_handle: Health, consumer: EventsConsumer,
23 ) -> Self {
24 Self {
25 topology_context: topology_context.clone(),
26 component_context: component_context.clone(),
27 component_registry,
28 health_handle: Some(health_handle),
29 consumer,
30 }
31 }
32
33 pub fn take_health_handle(&mut self) -> Health {
39 self.health_handle.take().expect("health handle already taken")
40 }
41
42 pub fn topology_context(&self) -> &TopologyContext {
44 &self.topology_context
45 }
46
47 pub fn component_context(&self) -> &ComponentContext {
49 &self.component_context
50 }
51
52 pub fn component_registry(&mut self) -> &ComponentRegistry {
54 &self.component_registry
55 }
56
57 pub fn events(&mut self) -> &mut EventsConsumer {
59 &mut self.consumer
60 }
61}