pub struct TopologyBlueprint { /* private fields */ }Expand description
A topology blueprint represents a directed graph of components.
A blueprint is assembled by adding components and connecting them together, and then run by adding it to a
Supervisor: TopologyBlueprint implements Supervisable, so there is no
standalone spawn/run method. A blueprint can only be initialized (and thus run) once.
Implementations§
Source§impl TopologyBlueprint
impl TopologyBlueprint
Sourcepub fn new(name: &str, component_registry: &ComponentRegistry) -> Self
pub fn new(name: &str, component_registry: &ComponentRegistry) -> Self
Creates an empty TopologyBlueprint with the given name.
Sourcepub fn with_interconnect_capacity(
&mut self,
capacity: NonZeroUsize,
) -> &mut Self
pub fn with_interconnect_capacity( &mut self, capacity: NonZeroUsize, ) -> &mut Self
Sets the capacity of interconnects in the topology.
Interconnects are used to connect components to one another. Once their capacity is reached, no more items can be sent through until in-flight items are processed. This will apply backpressure to the upstream components. Raising or lowering the capacity allows trading off throughput at the expense of memory usage.
Defaults to 128.
Sourcepub fn with_shutdown_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn with_shutdown_timeout(&mut self, timeout: Duration) -> &mut Self
Sets how long the topology waits for components to stop during graceful shutdown.
Defaults to 30 seconds.
Sourcepub fn with_health_registry(
&mut self,
health_registry: HealthRegistry,
) -> &mut Self
pub fn with_health_registry( &mut self, health_registry: HealthRegistry, ) -> &mut Self
Sets the health registry used when the topology is spawned.
This must be set before the blueprint is added to a supervisor; initialization fails otherwise.
Sourcepub fn with_memory_limiter(
&mut self,
memory_limiter: MemoryLimiter,
) -> &mut Self
pub fn with_memory_limiter( &mut self, memory_limiter: MemoryLimiter, ) -> &mut Self
Sets the memory limiter used when the topology is spawned.
This must be set before the blueprint is added to a supervisor; initialization fails otherwise.
Sourcepub fn with_environment_readiness<F>(&mut self, ready: F) -> &mut Self
pub fn with_environment_readiness<F>(&mut self, ready: F) -> &mut Self
Sets a readiness signal that must resolve before the topology starts its components.
When set, the topology is still built up front during initialization, but its components are not spawned until the given future resolves (or the topology is asked to shut down first). This is used to defer the topology from processing data until its dependencies – such as the environment provider’s metadata collectors – are ready.
Sourcepub fn topology_ready(&mut self) -> TopologyReady
pub fn topology_ready(&mut self) -> TopologyReady
Returns a handle for awaiting the readiness of the topology once it’s running.
This handle depends on observing the readiness of the individual topology components, and so must be called after
with_health_registry.
§Panics
Panics if the health registry has not been set, or if the blueprint has already been initialized.
Sourcepub fn with_ambient_worker_pool(&mut self) -> &mut Self
pub fn with_ambient_worker_pool(&mut self) -> &mut Self
Configures the topology to use the ambient Tokio runtime for component subtasks.
Component subtasks will be spawned on whatever runtime is currently active when the topology is initialized. This avoids creating a dedicated thread pool, which is useful for resource-constrained environments.
Sourcepub fn with_explicit_worker_pool(&mut self, handle: Handle) -> &mut Self
pub fn with_explicit_worker_pool(&mut self, handle: Handle) -> &mut Self
Configures the topology to use an externally provided Tokio runtime for component subtasks.
Component subtasks will be spawned on the runtime associated with the given handle.
Sourcepub fn add_source<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_source<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds a source component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn add_relay<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_relay<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds a relay component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn add_decoder<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_decoder<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds a decoder component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn add_transform<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_transform<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds a transform component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn add_destination<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_destination<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds a destination component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn add_encoder<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_encoder<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds an encoder component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn add_forwarder<I, B>(
&mut self,
component_id: I,
builder: B,
) -> Result<&mut Self, GenericError>
pub fn add_forwarder<I, B>( &mut self, component_id: I, builder: B, ) -> Result<&mut Self, GenericError>
Adds a forwarder component to the blueprint.
§Errors
If the component ID is invalid or the component can’t be added to the graph, an error is returned.
Sourcepub fn connect_components<MS, SI, MD, DI>(
&mut self,
upstream_output_component_ids: SI,
downstream_component_ids: DI,
) -> Result<&mut Self, GenericError>where
SI: AsComponentIds<MS>,
DI: AsComponentIds<MD>,
pub fn connect_components<MS, SI, MD, DI>(
&mut self,
upstream_output_component_ids: SI,
downstream_component_ids: DI,
) -> Result<&mut Self, GenericError>where
SI: AsComponentIds<MS>,
DI: AsComponentIds<MD>,
Connects one or more upstream component outputs to one or more downstream components.
This method allows for ergonomically defining many-to-one, one-to-many, and many-to-many connections to facilitate common patterns like fanning in many upstream components to a single downstream component, or fanning out a single upstream component to many downstream components.
When both there are both multiple upstream and downstream component IDs, connections resemble a mesh: every upstream component will be connected to every downstream component. This should be rare, but is technically supported.
§Errors
If any of the upstream or downstream component IDs are invalid or don’t exist, or if the data types between one of the upstream/downstream component pairs is incompatible, an error is returned.
Sourcepub fn connect_components_in_order<IT, I>(
&mut self,
ordered_component_ids: IT,
) -> Result<&mut Self, GenericError>
pub fn connect_components_in_order<IT, I>( &mut self, ordered_component_ids: IT, ) -> Result<&mut Self, GenericError>
Connects a set of component IDs to one another in a pairwise fashion.
This can be used to connect multiple components – each sharing only a single edge between one another – in a single call instead of multiple calls.
For example, passing ["first", "second", "third"] would connect first’s output to second’s input, and
second’s output to third’s input.
One caveat is that only the default output of a component can be used for connections past the first pair, as the identifier given must be able to describe both the component ID to send to as well as the component output ID to connect to the subsequent component. This limitation does not exist on the first component ID, since it is only used in the context of being a component output ID.
§Errors
If any of the component IDs are invalid or don’t exist, or if the data types between one of the upstream/downstream component pairs is incompatible, or if less than two component IDs are provided, an error is returned.
Care should be taken on failure as this method will not rollback any previously successful connections, which could leave the blueprint in an indeterminate state if some connections are made prior to hitting an error.
Trait Implementations§
Source§impl Supervisable for TopologyBlueprint
impl Supervisable for TopologyBlueprint
Source§fn shutdown_strategy(&self) -> ShutdownStrategy
fn shutdown_strategy(&self) -> ShutdownStrategy
Source§fn initialize<'life0, 'async_trait>(
&'life0 self,
shutdown: ShutdownHandle,
) -> Pin<Box<dyn Future<Output = Result<SupervisorFuture, InitializationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 self,
shutdown: ShutdownHandle,
) -> Pin<Box<dyn Future<Output = Result<SupervisorFuture, InitializationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for TopologyBlueprint
impl RefUnwindSafe for TopologyBlueprint
impl Send for TopologyBlueprint
impl Sync for TopologyBlueprint
impl Unpin for TopologyBlueprint
impl UnsafeUnpin for TopologyBlueprint
impl UnwindSafe for TopologyBlueprint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more