pub struct AppBuilder { /* private fields */ }Expand description
Collects the root modules of an app, then validates, boots or runs it.
Implementations§
Source§impl AppBuilder
impl AppBuilder
Sourcepub fn module(self, m: impl Module) -> Self
pub fn module(self, m: impl Module) -> Self
Adds a root module (imported by the implicit app root).
Sourcepub fn override_value<T: ?Sized + Send + Sync + 'static>(
self,
value: Arc<T>,
) -> Self
pub fn override_value<T: ?Sized + Send + Sync + 'static>( self, value: Arc<T>, ) -> Self
Replaces the unnamed provider of T wherever it is registered with
value (its factory never runs); registers value globally if no
module provides T. Meant for tests and fakes.
Sourcepub fn shutdown_timeout(self, d: Duration) -> Self
pub fn shutdown_timeout(self, d: Duration) -> Self
How long graceful shutdown waits for tracked tasks, and then for the
on_shutdown hooks (default 30 s each).
Sourcepub fn validate(&self) -> Result<GraphReport, BootErrors>
pub fn validate(&self) -> Result<GraphReport, BootErrors>
Validates the module graph without constructing any provider.
Sourcepub fn plugin_report(&self) -> Result<PluginsReport, BootErrors>
pub fn plugin_report(&self) -> Result<PluginsReport, BootErrors>
Validates the module graph (as validate) and
reports its plugins and what each of their modules adds. Nothing is
built.
use navree_kernel::{Module, ModuleBuilder, Navree};
struct AnnouncementsModule;
impl Module for AnnouncementsModule {
fn register(&self, m: &mut ModuleBuilder) {
m.plugin(navree_kernel::plugin_info!(title = "Announcements"));
}
}
fn main() -> Result<(), navree_kernel::BootErrors> {
let report = Navree::app().module(AnnouncementsModule).plugin_report()?;
println!("{report}");
Ok(())
}Sourcepub async fn boot(self) -> Result<App, BootErrors>
pub async fn boot(self) -> Result<App, BootErrors>
Validates the graph, constructs every singleton (modules in dependency
order), then runs on_init and on_bootstrap hooks.
Source§impl AppBuilder
impl AppBuilder
Sourcepub async fn run_with_args(self, args: Vec<String>) -> Result<(), BoxError>
pub async fn run_with_args(self, args: Vec<String>) -> Result<(), BoxError>
Runs a command line (without the program name):
check [--graph]validates the graph without constructing anything and prints a summary (or the module tree);help/listprints the commands;introspect [--json]validates the graph without constructing anything and prints it as JSON (GraphReport::to_json, with a"plugins"array asPluginsReport::to_jsonwrites it);plugins [--json]validates the graph without constructing anything and prints its plugins and what each adds (PluginsReport, or its JSON with--json); when the checks refuse the graph, it prints the listing first and fails with the refusals;plugin:publish <plugin> [--tag views|locales|config|files] [--force] [--dry-run]validates the graph without constructing anything and copies the files the plugin (a namespace or a plugin’s name) ships into the app’s folders below the current directory, one line per file; an existing file is kept without--force, every path is checked before the first write, and--dry-runwrites nothing. Theconfigtag (and no--tag) runs the app’sconfig:publish --plugin <namespace>, when the app has that command, after the files are checked and before they are written, so a refusal from either leaves nothing written;<name> [args...]boots the app, runs the registered command, then shuts the app down gracefully; a command marked offline skips the boot and the shutdown hooks;- no command runs
serveif a module registers it, elsehelp.
The built-ins plugins and plugin:publish yield: when a module of the
app registers a command of one of these names, that command runs
instead, with its arguments, and help and introspect no longer list
the built-in. A module of a plugin that is not one of the framework’s own
may not register a command of a built-in’s name.