dynamo_runtime/
pipeline.rs1use serde::{Deserialize, Serialize};
7
8mod nodes;
9pub use nodes::{
10 Operator, PipelineNode, PipelineOperator, SegmentSink, SegmentSource, Service, ServiceBackend,
11 ServiceFrontend, Sink, Source,
12};
13
14pub mod context;
15pub mod error;
16pub mod network;
17pub use network::egress::addressed_router::{AddressedPushRouter, AddressedRequest};
18pub use network::egress::push_router::{PushRouter, RouterMode};
19pub mod registry;
20
21pub use crate::engine::{
22 self as engine, AsyncEngine, AsyncEngineContext, AsyncEngineContextProvider, Data, DataStream,
23 Engine, EngineStream, EngineUnary, ResponseStream, async_trait,
24};
25pub use anyhow::Error;
26pub use context::Context;
27pub use error::{PipelineError, PipelineErrorExt, TwoPartCodecError};
28
29pub type SingleIn<T> = Context<T>;
32
33pub type ManyIn<T> = Context<DataStream<T>>;
36
37pub type SingleOut<T> = EngineUnary<T>;
39
40pub type ManyOut<T> = EngineStream<T>;
42
43pub type ServiceEngine<T, U> = Engine<T, U, Error>;
44
45pub type UnaryEngine<T, U> = ServiceEngine<SingleIn<T>, SingleOut<U>>;
47
48pub type ClientStreamingEngine<T, U> = ServiceEngine<ManyIn<T>, SingleOut<U>>;
52
53pub type ServerStreamingEngine<T, U> = ServiceEngine<SingleIn<T>, ManyOut<U>>;
55
56pub type BidirectionalStreamingEngine<T, U> = ServiceEngine<ManyIn<T>, ManyOut<U>>;
59
60pub trait AsyncTransportEngine<T: Data + PipelineIO, U: Data + PipelineIO>:
61 AsyncEngine<T, U, Error> + Send + Sync + 'static
62{
63}
64
65mod sealed {
68 use super::*;
69
70 #[allow(dead_code)]
71 pub struct Token;
72
73 pub trait Connectable {
74 type DataType: Data;
75 }
76
77 impl<T: Data> Connectable for Context<T> {
78 type DataType = T;
79 }
80 impl<T: Data> Connectable for EngineUnary<T> {
81 type DataType = T;
82 }
83 impl<T: Data> Connectable for EngineStream<T> {
84 type DataType = T;
85 }
86}
87
88pub trait PipelineIO: sealed::Connectable + AsyncEngineContextProvider + 'static {
89 fn id(&self) -> String;
90}
91
92impl<T: Data> PipelineIO for Context<T> {
93 fn id(&self) -> String {
94 self.id().to_string()
95 }
96}
97impl<T: Data> PipelineIO for EngineUnary<T> {
98 fn id(&self) -> String {
99 self.context().id().to_string()
100 }
101}
102impl<T: Data> PipelineIO for EngineStream<T> {
103 fn id(&self) -> String {
104 self.context().id().to_string()
105 }
106}
107
108#[derive(Serialize, Deserialize, Debug, Clone)]
109pub struct Event {
110 pub id: String,
111}