pub struct DynamicHub { /* private fields */ }Expand description
DynamicHub - an activation that routes to dynamically registered child activations
Unlike hub activations with hardcoded children (like Solar),
DynamicHub allows registering activations at runtime via .register().
§Direct Hosting
For a single activation, host it directly:
let solar = Arc::new(Solar::new());
TransportServer::builder(solar, converter).serve().await?;§Composition
For multiple top-level activations, use DynamicHub:
let hub = DynamicHub::with_namespace("myapp")
.register(Solar::new())
.register(Echo::new());Implementations§
Source§impl DynamicHub
impl DynamicHub
Sourcepub fn new(namespace: impl Into<String>) -> DynamicHub
pub fn new(namespace: impl Into<String>) -> DynamicHub
Create a new DynamicHub with explicit namespace
Unlike single activations which have fixed namespaces, DynamicHub is a composition tool that can be named based on your application. Common choices:
- “hub” - generic default
- “substrate” - for substrate server
- “myapp” - for your application name
The namespace appears in method calls: {namespace}.call, {namespace}.schema
Sourcepub fn with_namespace(namespace: impl Into<String>) -> DynamicHub
👎Deprecated since 0.3.0: Use DynamicHub::new(namespace) instead
pub fn with_namespace(namespace: impl Into<String>) -> DynamicHub
Deprecated: Use new() with explicit namespace instead
Sourcepub fn runtime_namespace(&self) -> &str
pub fn runtime_namespace(&self) -> &str
Get the runtime namespace for this DynamicHub instance
Sourcepub fn registry(&self) -> RwLockReadGuard<'_, PluginRegistry>
pub fn registry(&self) -> RwLockReadGuard<'_, PluginRegistry>
Get access to the activation registry
Sourcepub fn register<A>(self, activation: A) -> DynamicHubwhere
A: Activation + Clone,
pub fn register<A>(self, activation: A) -> DynamicHubwhere
A: Activation + Clone,
Register an activation
Sourcepub fn register_hub<A>(self, activation: A) -> DynamicHub
pub fn register_hub<A>(self, activation: A) -> DynamicHub
Register a hub activation that supports nested routing
Hub activations implement ChildRouter, enabling direct nested method calls
like hub.solar.mercury.info at the RPC layer (no hub.call indirection).
Sourcepub fn list_methods(&self) -> Vec<String>
pub fn list_methods(&self) -> Vec<String>
List all methods across all activations
Sourcepub fn list_activations_info(&self) -> Vec<ActivationInfo>
pub fn list_activations_info(&self) -> Vec<ActivationInfo>
List all activations (including this hub itself)
Sourcepub fn compute_hash(&self) -> String
pub fn compute_hash(&self) -> String
Compute hash for cache invalidation
Returns the hash from the recursive plugin schema. This hash changes whenever any method definition or child plugin changes.
Sourcepub async fn route(
&self,
method: &str,
params: Value,
) -> Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>
pub async fn route( &self, method: &str, params: Value, ) -> Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>
Route a call to the appropriate activation
Sourcepub async fn do_resolve_handle(
&self,
handle: &Handle,
) -> Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>
pub async fn do_resolve_handle( &self, handle: &Handle, ) -> Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>
Resolve a handle using the activation registry
Looks up the activation by its UUID in the registry.
Sourcepub fn get_activation_schema(&self, namespace: &str) -> Option<Schema>
pub fn get_activation_schema(&self, namespace: &str) -> Option<Schema>
Get activation schema
Sourcepub fn registry_snapshot(&self) -> PluginRegistrySnapshot
pub fn registry_snapshot(&self) -> PluginRegistrySnapshot
Get a snapshot of the activation registry (safe to use outside locks)
Sourcepub fn lookup_plugin(&self, id: Uuid) -> Option<String>
pub fn lookup_plugin(&self, id: Uuid) -> Option<String>
Look up an activation path by its UUID
Sourcepub fn lookup_plugin_by_path(&self, path: &str) -> Option<Uuid>
pub fn lookup_plugin_by_path(&self, path: &str) -> Option<Uuid>
Look up an activation UUID by its path
Sourcepub fn list_plugin_schemas(&self) -> Vec<PluginSchema>
pub fn list_plugin_schemas(&self) -> Vec<PluginSchema>
Get activation schemas for all activations (including this hub itself)
Sourcepub fn list_full_schemas(&self) -> Vec<PluginSchema>
👎Deprecated: Use list_plugin_schemas instead
pub fn list_full_schemas(&self) -> Vec<PluginSchema>
Deprecated: use list_plugin_schemas instead
Sourcepub fn get_method_help(&self, method: &str) -> Option<String>
pub fn get_method_help(&self, method: &str) -> Option<String>
Get help for a method
Sourcepub fn plugin_children(&self) -> Vec<ChildSummary>
pub fn plugin_children(&self) -> Vec<ChildSummary>
Get child activation summaries (for hub functionality)
Called by hub-macro when hub flag is set
Sourcepub fn into_rpc_module(self) -> Result<RpcModule<()>, RegisterMethodError>
pub fn into_rpc_module(self) -> Result<RpcModule<()>, RegisterMethodError>
Convert to RPC module
Sourcepub fn arc_into_rpc_module(
hub: Arc<DynamicHub>,
) -> Result<RpcModule<()>, RegisterMethodError>
pub fn arc_into_rpc_module( hub: Arc<DynamicHub>, ) -> Result<RpcModule<()>, RegisterMethodError>
Convert Arc
Unlike into_rpc_module, this keeps the Arc
Trait Implementations§
Source§impl Activation for DynamicHub
impl Activation for DynamicHub
type Methods = DynamicHubMethod
fn namespace(&self) -> &str
fn version(&self) -> &str
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn long_description(&self) -> Option<&str>
fn long_description(&self) -> Option<&str>
fn methods(&self) -> Vec<&str>
fn method_help(&self, method: &str) -> Option<String>
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DynamicHub: 'async_trait,
fn into_rpc_methods(self) -> Methods
Source§fn plugin_schema(&self) -> PluginSchema
fn plugin_schema(&self) -> PluginSchema
Source§fn plugin_id(&self) -> Uuid
fn plugin_id(&self) -> Uuid
fn resolve_handle<'life0, 'life1, 'async_trait>(
&'life0 self,
_handle: &'life1 Handle,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§impl ChildRouter for DynamicHub
ChildRouter implementation for DynamicHub
impl ChildRouter for DynamicHub
ChildRouter implementation for DynamicHub
This enables nested routing through registered activations. e.g., hub.call(“solar.mercury.info”) routes to solar → mercury → info
Source§fn router_namespace(&self) -> &str
fn router_namespace(&self) -> &str
Source§fn router_call<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DynamicHub: 'async_trait,
fn router_call<'life0, 'life1, 'async_trait>(
&'life0 self,
method: &'life1 str,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>, PlexusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DynamicHub: 'async_trait,
Source§fn get_child<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Box<dyn ChildRouter>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DynamicHub: 'async_trait,
fn get_child<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<Box<dyn ChildRouter>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DynamicHub: 'async_trait,
Source§impl Clone for DynamicHub
impl Clone for DynamicHub
Source§fn clone(&self) -> DynamicHub
fn clone(&self) -> DynamicHub
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl DynamicHubRpcServer for DynamicHub
impl DynamicHubRpcServer for DynamicHub
Source§fn call<'life0, 'async_trait>(
&'life0 self,
pending: PendingSubscriptionSink,
method: String,
params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<(), SubscriptionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
DynamicHub: 'async_trait,
fn call<'life0, 'async_trait>(
&'life0 self,
pending: PendingSubscriptionSink,
method: String,
params: Option<Value>,
) -> Pin<Box<dyn Future<Output = Result<(), SubscriptionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
DynamicHub: 'async_trait,
Source§fn hash<'life0, 'async_trait>(
&'life0 self,
pending: PendingSubscriptionSink,
) -> Pin<Box<dyn Future<Output = Result<(), SubscriptionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
DynamicHub: 'async_trait,
fn hash<'life0, 'async_trait>(
&'life0 self,
pending: PendingSubscriptionSink,
) -> Pin<Box<dyn Future<Output = Result<(), SubscriptionError>> + Send + 'async_trait>>where
'life0: 'async_trait,
DynamicHub: 'async_trait,
Auto Trait Implementations§
impl Freeze for DynamicHub
impl !RefUnwindSafe for DynamicHub
impl Send for DynamicHub
impl Sync for DynamicHub
impl Unpin for DynamicHub
impl !UnwindSafe for DynamicHub
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more