pub struct HostRuntime { /* private fields */ }Expand description
Owns the lifecycle orchestration for ToolKit: encapsulates all runtime
state and drives gears through the full lifecycle (see gear docs).
Implementations§
Source§impl HostRuntime
impl HostRuntime
Sourcepub fn new(
registry: GearRegistry,
gears_cfg: Arc<dyn ConfigProvider>,
db_options: DbOptions,
client_hub: Arc<ClientHub>,
cancel: CancellationToken,
instance_id: Uuid,
oop_options: Option<OopSpawnOptions>,
) -> Self
pub fn new( registry: GearRegistry, gears_cfg: Arc<dyn ConfigProvider>, db_options: DbOptions, client_hub: Arc<ClientHub>, cancel: CancellationToken, instance_id: Uuid, oop_options: Option<OopSpawnOptions>, ) -> Self
Create a new HostRuntime instance.
This prepares all runtime components but does not start any lifecycle phases.
Sourcepub fn with_init_deadline(self, deadline: Duration) -> Self
pub fn with_init_deadline(self, deadline: Duration) -> Self
Set the per-gear deadline for context construction and Gear::init.
A stuck .await returns RegistryError::InitTimeout; a synchronous
block force-exits the process. Defaults to DEFAULT_INIT_DEADLINE.
Sourcepub fn with_shutdown_deadline(self, deadline: Duration) -> Self
pub fn with_shutdown_deadline(self, deadline: Duration) -> Self
Set a custom shutdown deadline for graceful gear stop.
This is the maximum time the runtime will wait for each gear to stop gracefully before sending the hard-stop signal (cancelling the deadline token).
§Relationship with WithLifecycle::stop_timeout
When using WithLifecycle, its stop_timeout (default 30s) races against this
shutdown_deadline (default DEFAULT_SHUTDOWN_DEADLINE, 35s). To ensure
deterministic behavior:
WithLifecycle::stop_timeoutshould be less thanshutdown_deadline- This allows the lifecycle’s internal timeout to trigger first for graceful cleanup
- The runtime’s
deadline_tokenthen acts as a hard backstop
Example: stop_timeout = 30s, shutdown_deadline = 35s
Sourcepub fn with_internal_token_provider(
self,
provider: Option<InternalTokenProvider>,
) -> Self
pub fn with_internal_token_provider( self, provider: Option<InternalTokenProvider>, ) -> Self
Set the process-wide platform-plane credential source, applied to every
GearCtx this runtime builds so
#[toolkit::provides]-generated clients attach X-ToolKit-Internal-Token
on platform-plane methods. None (Profile 1 / in-process, or no
credential configured) attaches nothing.
Sourcepub async fn run_pre_init_phase(&self) -> Result<(), RegistryError>
pub async fn run_pre_init_phase(&self) -> Result<(), RegistryError>
PRE_INIT phase over every gear, the system group first
(migration-only mode).
§Errors
Returns RegistryError if runtime wiring or a pre_init fails.
Sourcepub async fn run_gear_phases(self) -> Result<()>
pub async fn run_gear_phases(self) -> Result<()>
Run the full gear lifecycle (all phases).
This is the standard entry point for normal application execution. It runs all phases from pre-init through shutdown.
§Errors
Returns an error if any gear phase fails during execution.
Sourcepub async fn run_migration_phases(self) -> Result<()>
pub async fn run_migration_phases(self) -> Result<()>
Run only the migration phases (pre-init + DB migration).
This is designed for cloud deployment workflows where database migrations need to run as a separate step before starting the application. The process exits after migrations complete.
§Errors
Returns an error if pre-init or migration phases fail.
Source§impl HostRuntime
Out-of-process HTTP serving lifecycle (cpt-cf-component-oop-bootstrap).
impl HostRuntime
Out-of-process HTTP serving lifecycle (cpt-cf-component-oop-bootstrap).
Sourcepub async fn run_oop_serving(self, options: OopServeOptions) -> Result<()>
pub async fn run_oop_serving(self, options: OopServeOptions) -> Result<()>
Run the full OoP gear lifecycle: phases (pre_init … start), then
serve the composed router with framework probes, background
self-registration, dependency resolution, and graceful drain, then the
stop phase.
The listener binds first. The system group’s routes attach as
soon as it started — platform-plane calls only, tenant-plane calls get
503 — and the process is present in the directory then if its
advertised gear is a system gear. The application group’s routes
attach on the same listener once it started.
§Errors
Returns an error if any lifecycle phase or the HTTP server fails.
Auto Trait Implementations§
impl !Freeze for HostRuntime
impl !RefUnwindSafe for HostRuntime
impl !UnwindSafe for HostRuntime
impl Forget for HostRuntime
impl Move for HostRuntime
impl Send for HostRuntimewhere
RawVecInner: Send,
&'static str: Send,
&'static [&'static str]: Send,
Arc<dyn Gear>: Send,
Arc<dyn DatabaseCapability>: Send,
Arc<dyn RestApiCapability>: Send,
Arc<dyn ApiGatewayCapability>: Send,
Arc<dyn RunnableCapability>: Send,
Arc<dyn SystemCapability>: Send,
Arc<dyn GrpcHubCapability>: Send,
Arc<dyn GrpcServiceCapability>: Send,
Arc<dyn GtsPublicationCapability>: Send,
Arc<dyn ConfigProvider>: Send,
Arc<ClientHub>: Send,
Arc<TreeNode>: Send,
Arc<dyn Fn() -> CredentialState + Sync + Send>: Send,
Arc<RwLock<RawRwLock, HashMap<String, Arc<GtsManifest>>>>: Send,
Arc<DbManager>: Send,
Arc<GearManager>: Send,
Arc<GrpcInstallerStore>: Send,
Arc<DependencyChecker>: Send,
Arc<RestAdvertiser>: Send,
Mutex<RawMutex, Option<Arc<PresenceManager>>>: Send,
Mutex<RawMutex, HashSet<&'static str>>: Send,
Mutex<RawMutex, HashSet<usize>>: Send,
Arc<Mutex<RawMutex, BTreeMap<String, BTreeSet<Probe>>>>: Send,
RawTable<(String, String)>: Send,
BoxRaw<dyn OopBackend>: Send,
impl Sync for HostRuntimewhere
RawVecInner: Sync,
Arc<dyn Gear>: Sync,
Arc<dyn DatabaseCapability>: Sync,
Arc<dyn RestApiCapability>: Sync,
Arc<dyn ApiGatewayCapability>: Sync,
Arc<dyn RunnableCapability>: Sync,
Arc<dyn SystemCapability>: Sync,
Arc<dyn GrpcHubCapability>: Sync,
Arc<dyn GrpcServiceCapability>: Sync,
Arc<dyn GtsPublicationCapability>: Sync,
Arc<dyn ConfigProvider>: Sync,
Arc<ClientHub>: Sync,
Arc<TreeNode>: Sync,
Arc<dyn Fn() -> CredentialState + Sync + Send>: Sync,
Arc<RwLock<RawRwLock, HashMap<String, Arc<GtsManifest>>>>: Sync,
Arc<DbManager>: Sync,
Arc<GearManager>: Sync,
Arc<GrpcInstallerStore>: Sync,
Arc<DependencyChecker>: Sync,
Arc<RestAdvertiser>: Sync,
Mutex<RawMutex, Option<Arc<PresenceManager>>>: Sync,
Mutex<RawMutex, HashSet<&'static str>>: Sync,
Mutex<RawMutex, HashSet<usize>>: Sync,
Arc<Mutex<RawMutex, BTreeMap<String, BTreeSet<Probe>>>>: Sync,
RawTable<(String, String)>: Sync,
BoxRaw<dyn OopBackend>: Sync,
impl Unpin for HostRuntimewhere
*const u8 is !null: Unpin,
&'static str: Unpin,
&'static [&'static str]: Unpin,
Arc<dyn Gear>: Unpin,
Arc<dyn DatabaseCapability>: Unpin,
Arc<dyn RestApiCapability>: Unpin,
Arc<dyn ApiGatewayCapability>: Unpin,
Arc<dyn RunnableCapability>: Unpin,
Arc<dyn SystemCapability>: Unpin,
Arc<dyn GrpcHubCapability>: Unpin,
Arc<dyn GrpcServiceCapability>: Unpin,
Arc<dyn GtsPublicationCapability>: Unpin,
Arc<dyn ConfigProvider>: Unpin,
Arc<ClientHub>: Unpin,
Arc<TreeNode>: Unpin,
Arc<dyn Fn() -> CredentialState + Sync + Send>: Unpin,
Arc<RwLock<RawRwLock, HashMap<String, Arc<GtsManifest>>>>: Unpin,
Arc<DbManager>: Unpin,
Arc<GearManager>: Unpin,
Arc<GrpcInstallerStore>: Unpin,
Arc<DependencyChecker>: Unpin,
Arc<RestAdvertiser>: Unpin,
Align1<u8>: Unpin,
Arc<PresenceManager>: Unpin,
Arc<Mutex<RawMutex, BTreeMap<String, BTreeSet<Probe>>>>: Unpin,
Box<dyn OopBackend>: Unpin,
impl UnsafeUnpin for HostRuntimewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<GearEntry>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, Arc<dyn GrpcServiceCapability>)>: UnsafeUnpin,
*const ArcInner<dyn ConfigProvider> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ConfigProvider>>: UnsafeUnpin,
*const ArcInner<ClientHub> is !null: UnsafeUnpin,
PhantomData<ArcInner<ClientHub>>: UnsafeUnpin,
*const ArcInner<TreeNode> is !null: UnsafeUnpin,
PhantomData<ArcInner<TreeNode>>: UnsafeUnpin,
*const ArcInner<dyn Fn() -> CredentialState + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn() -> CredentialState + Sync + Send>>: UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, HashMap<String, Arc<GtsManifest>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<RawRwLock, HashMap<String, Arc<GtsManifest>>>>>: UnsafeUnpin,
*const ArcInner<DbManager> is !null: UnsafeUnpin,
PhantomData<ArcInner<DbManager>>: UnsafeUnpin,
*const ArcInner<GearManager> is !null: UnsafeUnpin,
PhantomData<ArcInner<GearManager>>: UnsafeUnpin,
*const ArcInner<GrpcInstallerStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<GrpcInstallerStore>>: UnsafeUnpin,
*const ArcInner<DependencyChecker> is !null: UnsafeUnpin,
PhantomData<ArcInner<DependencyChecker>>: UnsafeUnpin,
*const ArcInner<RestAdvertiser> is !null: UnsafeUnpin,
PhantomData<ArcInner<RestAdvertiser>>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const ArcInner<PresenceManager> is !null: UnsafeUnpin,
PhantomData<ArcInner<PresenceManager>>: UnsafeUnpin,
PhantomData<(&'static str, ())>: UnsafeUnpin,
PhantomData<(usize, ())>: UnsafeUnpin,
*const ArcInner<Mutex<RawMutex, BTreeMap<String, BTreeSet<Probe>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<RawMutex, BTreeMap<String, BTreeSet<Probe>>>>>: UnsafeUnpin,
PhantomData<OopGearSpawnConfig>: UnsafeUnpin,
*const dyn OopBackend is !null: UnsafeUnpin,
PhantomData<dyn OopBackend>: UnsafeUnpin,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read moreSource§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§impl<T> WithSecurityContext for T
impl<T> WithSecurityContext for T
Source§fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>where
T: Sized,
fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>where
T: Sized,
Secured wrapper. Read more