saluki_core/components/transforms/
context.rs1use memory_accounting::ComponentRegistry;
2use saluki_health::Health;
3
4use crate::{
5 components::ComponentContext,
6 topology::{EventsConsumer, EventsDispatcher, TopologyContext},
7};
8
9pub struct TransformContext {
11 topology_context: TopologyContext,
12 component_context: ComponentContext,
13 component_registry: ComponentRegistry,
14 health_handle: Option<Health>,
15 dispatcher: EventsDispatcher,
16 consumer: EventsConsumer,
17}
18
19impl TransformContext {
20 pub fn new(
22 topology_context: &TopologyContext, component_context: &ComponentContext,
23 component_registry: ComponentRegistry, health_handle: Health, dispatcher: EventsDispatcher,
24 consumer: EventsConsumer,
25 ) -> Self {
26 Self {
27 topology_context: topology_context.clone(),
28 component_context: component_context.clone(),
29 component_registry,
30 health_handle: Some(health_handle),
31 dispatcher,
32 consumer,
33 }
34 }
35
36 pub fn take_health_handle(&mut self) -> Health {
42 self.health_handle.take().expect("health handle already taken")
43 }
44
45 pub fn topology_context(&self) -> &TopologyContext {
47 &self.topology_context
48 }
49
50 pub fn component_context(&self) -> &ComponentContext {
52 &self.component_context
53 }
54
55 pub fn dispatcher(&self) -> &EventsDispatcher {
57 &self.dispatcher
58 }
59
60 pub fn events(&mut self) -> &mut EventsConsumer {
62 &mut self.consumer
63 }
64
65 pub fn component_registry(&self) -> &ComponentRegistry {
67 &self.component_registry
68 }
69}