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