dynamo_runtime/
pipeline.rs1use serde::{Deserialize, Serialize};
19
20mod nodes;
21pub use nodes::{
22 Operator, PipelineNode, PipelineOperator, SegmentSink, SegmentSource, Service, ServiceBackend,
23 ServiceFrontend, Sink, Source,
24};
25
26pub mod context;
27pub mod error;
28pub mod network;
29pub use network::egress::addressed_router::{AddressedPushRouter, AddressedRequest};
30pub use network::egress::push_router::{PushRouter, RouterMode};
31pub mod registry;
32
33pub use crate::engine::{
34 self as engine, async_trait, AsyncEngine, AsyncEngineContext, AsyncEngineContextProvider, Data,
35 DataStream, Engine, EngineStream, EngineUnary, ResponseStream,
36};
37pub use anyhow::Error;
38pub use context::Context;
39pub use error::{PipelineError, PipelineErrorExt, TwoPartCodecError};
40
41pub type SingleIn<T> = Context<T>;
44
45pub type ManyIn<T> = Context<DataStream<T>>;
48
49pub type SingleOut<T> = EngineUnary<T>;
51
52pub type ManyOut<T> = EngineStream<T>;
54
55pub type ServiceEngine<T, U> = Engine<T, U, Error>;
56
57pub type UnaryEngine<T, U> = ServiceEngine<SingleIn<T>, SingleOut<U>>;
59
60pub type ClientStreamingEngine<T, U> = ServiceEngine<ManyIn<T>, SingleOut<U>>;
64
65pub type ServerStreamingEngine<T, U> = ServiceEngine<SingleIn<T>, ManyOut<U>>;
67
68pub type BidirectionalStreamingEngine<T, U> = ServiceEngine<ManyIn<T>, ManyOut<U>>;
71
72pub trait AsyncTransportEngine<T: PipelineIO, U: PipelineIO>:
73 AsyncEngine<T, U, Error> + Send + Sync + 'static
74{
75}
76
77mod sealed {
80 use super::*;
81
82 #[allow(dead_code)]
83 pub struct Token;
84
85 pub trait Connectable {
86 type DataType: Data;
87 }
88
89 impl<T: Data> Connectable for Context<T> {
90 type DataType = T;
91 }
92 impl<T: Data> Connectable for EngineUnary<T> {
93 type DataType = T;
94 }
95 impl<T: Data> Connectable for EngineStream<T> {
96 type DataType = T;
97 }
98}
99
100pub trait PipelineIO: Data + sealed::Connectable + AsyncEngineContextProvider {
101 fn id(&self) -> String;
102}
103
104impl<T: Data> PipelineIO for Context<T> {
105 fn id(&self) -> String {
106 self.id().to_string()
107 }
108}
109impl<T: Data> PipelineIO for EngineUnary<T> {
110 fn id(&self) -> String {
111 self.context().id().to_string()
112 }
113}
114impl<T: Data> PipelineIO for EngineStream<T> {
115 fn id(&self) -> String {
116 self.context().id().to_string()
117 }
118}
119
120#[derive(Serialize, Deserialize, Debug, Clone)]
121pub struct Event {
122 pub id: String,
123}