pub struct Node<S: NodeState = Attached> { /* private fields */ }Expand description
Node — Hyper wired to a runtime configuration (and optionally a workload).
A Node<Init> is produced by Node::from_config_file or
Node::from_hyper; it carries Hyper + actr_config::RuntimeConfig
but has not yet been attached. Call one of the attach methods to progress
into Node<Attached>, then register().start() into a running
ActrRef:
Node::from_config_file(path) -> Node<Init>
.attach(package) -> Node<Attached> (attach: wasm / dyn lib)
.link(workload) -> Node<Attached> (link: static lib)
Node<Attached>.register(ais) -> Node<Registered>
Node<Registered>.start() -> ActrRefThe default type parameter Attached means writing Node unqualified
refers to the attached state; start() only exists on Node<Registered>.
Implementations§
Source§impl Node
impl Node
Sourcepub async fn from_config_file(
path: impl AsRef<Path>,
) -> Result<Node<Init>, HyperError>
pub async fn from_config_file( path: impl AsRef<Path>, ) -> Result<Node<Init>, HyperError>
Load actr.toml from disk, build the underlying Hyper from the
[hyper] section (or an explicit [[trust]] / [hyper.trust]
anchor set), and return a Node<Init> ready to attach a workload.
The caller is expected to drive the typestate chain themselves:
let actr_ref = Node::from_config_file("actr.toml").await?
.attach(&package).await?
.register(&ais_endpoint).await?
.start().await?;For a one-shot sugar covering the entire chain see
Node::run_from_config.
Sourcepub fn from_hyper(hyper: Hyper, runtime_config: RuntimeConfig) -> Node<Init>
pub fn from_hyper(hyper: Hyper, runtime_config: RuntimeConfig) -> Node<Init>
Escape-hatch constructor: wrap an already-built Hyper plus a
pre-loaded actr_config::RuntimeConfig into a Node<Init>.
Use this when you need direct control over HyperConfig
construction (custom trust chain, injected platform provider, etc.)
and cannot drive the whole flow through
Node::from_config_file.
Sourcepub async fn run_from_config(
path: impl AsRef<Path>,
package: &WorkloadPackage,
) -> Result<ActrRef, HyperError>
pub async fn run_from_config( path: impl AsRef<Path>, package: &WorkloadPackage, ) -> Result<ActrRef, HyperError>
One-shot sugar: from_config_file(path).attach(package).register().start().
Loads the runtime configuration from path, attaches the given
workload package, registers with AIS at the [ais_endpoint] URL
from the config, and starts the node, returning a live
ActrRef. Use the typestate chain directly when you need to
interleave create_network_event_handle or swap in a custom
service_spec via register_with.
Source§impl Node<Init>
impl Node<Init>
Sourcepub fn runtime_config(&self) -> &RuntimeConfig
pub fn runtime_config(&self) -> &RuntimeConfig
Read-only view of the runtime configuration pending attachment.
Useful for callers that need to configure observability /
tracing subscribers from the config before driving attach.
Sourcepub fn with_actor_type(self, actor_type: ActrType) -> Self
pub fn with_actor_type(self, actor_type: ActrType) -> Self
Override the runtime actor type before attaching or linking a workload.
Node::from_config_file can synthesize a placeholder actor type when
the runtime config has no package manifest. Linked/static hosts use this
method to provide the concrete actor identity used for AIS registration.
Source§impl Node<Init>
impl Node<Init>
Sourcepub async fn attach(
self,
package: &WorkloadPackage,
) -> Result<Node<Attached>, HyperError>
pub async fn attach( self, package: &WorkloadPackage, ) -> Result<Node<Attached>, HyperError>
Bind a verified WorkloadPackage to this node.
Equivalent to the former Hyper::attach — verifies the package
signature through the configured TrustProvider, loads its guest
binary (WASM or dynclib), and advances the node to
Node<Attached>.
Attach a packaged workload (wasm / dyn lib) to this node.
Sourcepub async fn link<W: Workload>(
self,
workload: W,
) -> Result<Node<Attached>, HyperError>
pub async fn link<W: Workload>( self, workload: W, ) -> Result<Node<Attached>, HyperError>
Link a generic actr_framework::Workload implementation
(static lib) into this node.
This is the preferred link path for Rust hosts: the
workload is wrapped in a [workload::WorkloadAdapter] so that its
associated actr_framework::MessageDispatcher drives inbound
RPC dispatch and its hook methods are bridged into the node’s
observer plumbing.
Source§impl Node<Attached>
impl Node<Attached>
Sourcepub async fn register(
self,
ais_endpoint: &str,
) -> Result<Node<Registered>, HyperError>
pub async fn register( self, ais_endpoint: &str, ) -> Result<Node<Registered>, HyperError>
Register with AIS, obtain an AId credential, and inject it into this
attached node. Consumes Node<Attached> and returns Node<Registered>.
realm_id, acl, and realm_secret come from the attached
[RuntimeConfig]; service_spec is derived from the package’s proto
exports when a package-backed attach was used. Linked attachments
register from the runtime config’s actor metadata instead.
Sourcepub async fn register_with(
self,
ais_endpoint: &str,
service_spec: Option<ServiceSpec>,
) -> Result<Node<Registered>, HyperError>
pub async fn register_with( self, ais_endpoint: &str, service_spec: Option<ServiceSpec>, ) -> Result<Node<Registered>, HyperError>
Register with AIS using an explicit service_spec.
This skips package-based service_spec derivation for
package-backed attachments. Linked attachments use the supplied
service_spec together with the runtime config’s actor metadata.
Sourcepub fn create_network_event_handle(
&mut self,
debounce_ms: u64,
) -> NetworkEventHandle
pub fn create_network_event_handle( &mut self, debounce_ms: u64, ) -> NetworkEventHandle
Create a network event handle for platform callbacks. Must be called
before Node::start.
Sourcepub fn ais_endpoint(&self) -> &str
pub fn ais_endpoint(&self) -> &str
AIS endpoint URL resolved from the attached [RuntimeConfig].
Convenience accessor for callers that just drove from_config_file
attachand need the endpoint to pass intoregister.
Source§impl Node<Registered>
impl Node<Registered>
Sourcepub async fn start(self) -> ActorResult<ActrRef>
pub async fn start(self) -> ActorResult<ActrRef>
Start the attached, registered node and return the live ActrRef.
Sourcepub fn create_network_event_handle(
&mut self,
debounce_ms: u64,
) -> NetworkEventHandle
pub fn create_network_event_handle( &mut self, debounce_ms: u64, ) -> NetworkEventHandle
Create a network event handle for platform callbacks. Must be called
before Node::start.
Auto Trait Implementations§
impl<S = Attached> !Freeze for Node<S>
impl<S = Attached> !RefUnwindSafe for Node<S>
impl<S = Attached> !UnwindSafe for Node<S>
impl<S> Send for Node<S>where
S: Send,
impl<S> Sync for Node<S>where
S: Sync,
impl<S> Unpin for Node<S>where
S: Unpin,
impl<S> UnsafeUnpin for Node<S>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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