pub struct ComponentRegistry { /* private fields */ }Expand description
A registry for components for tracking memory bounds and runtime memory usage.
This registry provides a unified interface for declaring the memory bounds of a component, as well as registering
that component for runtime memory usage tracking when using the tracking allocator implementation in saluki-common.
§Components
Components are any logical grouping of memory usage within a program, and they can be arbitrarily nested.
For example, a data plane will generally have a topology that defines the components used to accept, process, and forward data. The topology itself could be considered a component, and each individual source, transform, and destination within it could be subcomponents of the topology.
Components are generally meant to be tied to something that has its own memory bounds and is somewhat standalone,
but this isn’t an absolute requirement and components can be nested more granularly for organizational/aesthetic
purposes. Again, for example, one might opt to create a component in their topology for each component type –
sources, transforms, and destinations – and then add the actual instances of those components as subcomponents to
each grouping, leading to a nested structure such as topology/sources/source1, topology/transforms/transform1,
and so on.
§Bounds
Every component is able to define memory bounds for itself and its subcomponents. A builder-style API is exposed to allow for ergonomically defining these bounds – both minimum and firm – for components, as well as extending the nestable aspect of the registry itself to the bounds builder, allowing for flexibility in where components are defined from and how they’re nested.
§Allocation tracking
Every component is also able to be registered with its own resource group when using the tracking allocator implementation. This is done on demand when the component’s token is requested, which avoids polluting the tracking allocator with components that are never actually used, such as those used for organizational/aesthetic purposes.
Implementations§
Source§impl ComponentRegistry
impl ComponentRegistry
Sourcepub fn root(&self) -> ComponentRegistryHandle
pub fn root(&self) -> ComponentRegistryHandle
Creates a handle to this registry.
The handle provides read-only access to root-level operations like creating API handlers and verifying bounds. It can be freely cloned and shared.
Sourcepub fn bounds_builder(
&self,
id: &SubsystemIdentifier,
) -> MemoryBoundsBuilder<'_>
pub fn bounds_builder( &self, id: &SubsystemIdentifier, ) -> MemoryBoundsBuilder<'_>
Gets a bounds builder for the component identified by id, creating the component – and any intermediate
components – if it doesn’t already exist.
id is a fully qualified, absolute identifier: the component is addressed directly from the root, so callers
never need to track how deeply nested a registry is.
Sourcepub fn get_resource_group_token(
&self,
id: &SubsystemIdentifier,
) -> ResourceGroupToken
pub fn get_resource_group_token( &self, id: &SubsystemIdentifier, ) -> ResourceGroupToken
Gets the resource group tracking token for the component identified by id, creating the component – and any
intermediate components – if it doesn’t already exist.
The component’s resource group is registered (using its full name) the first time its token is requested. id
is a fully qualified, absolute identifier, addressed directly from the root.
Sourcepub fn as_bounds(&self) -> ComponentBounds
pub fn as_bounds(&self) -> ComponentBounds
Gets the memory bounds for all components in the registry.
Trait Implementations§
Source§impl Clone for ComponentRegistry
impl Clone for ComponentRegistry
Source§fn clone(&self) -> ComponentRegistry
fn clone(&self) -> ComponentRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ComponentRegistry
impl RefUnwindSafe for ComponentRegistry
impl Send for ComponentRegistry
impl Sync for ComponentRegistry
impl Unpin for ComponentRegistry
impl UnwindSafe for ComponentRegistry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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