pub struct Bootstrap { /* private fields */ }Expand description
Builds and serves a Laterite application.
Implementations§
Source§impl Bootstrap
impl Bootstrap
Sourcepub fn new(config_dir: impl Into<PathBuf>) -> Self
pub fn new(config_dir: impl Into<PathBuf>) -> Self
Loads config from config_dir (default.toml, the APP_ENV overlay, and
local.toml). Env vars override under the prefix the config declares as
app.env_prefix, else DEFAULT_ENV_PREFIX; Bootstrap::env_prefix
overrides both.
Sourcepub fn env_prefix(self, prefix: impl Into<String>) -> Self
pub fn env_prefix(self, prefix: impl Into<String>) -> Self
Overrides the config env-var prefix from code, above the config’s own
app.env_prefix declaration and DEFAULT_ENV_PREFIX.
Sourcepub fn module(self, module: impl Module) -> Self
pub fn module(self, module: impl Module) -> Self
Registers one of the application’s own modules, after the built-in ones. Its
migrations and contributions run after those of the modules it names in
requires. App modules are load-critical: a failure at boot aborts, rather
than being quarantined like a plugin registered with Bootstrap::modules.
Sourcepub fn modules(self, modules: Vec<Box<dyn Module>>) -> Self
pub fn modules(self, modules: Vec<Box<dyn Module>>) -> Self
Registers a set of plugins, typically the generated plugins-manifest.
Plugins are isolated at boot: one that fails to migrate or register is
quarantined (logged and skipped, taking its dependents with it) rather than
aborting the whole application.
Sourcepub fn extend(
self,
f: impl FnOnce(Router, &BootstrapCtx) -> Router + 'static,
) -> Self
pub fn extend( self, f: impl FnOnce(Router, &BootstrapCtx) -> Router + 'static, ) -> Self
Merges the app’s own routes onto the admin router before serving. The
closure gets the assembled router and a BootstrapCtx.
Sourcepub async fn serve(self) -> Result<()>
pub async fn serve(self) -> Result<()>
Loads config, connects, migrates, builds the router, and serves, with
the queue’s workers beside it when queue.mode is worker. Uses a
systemfd-inherited socket in development, else binds the configured
address. Stops on Ctrl-C or SIGTERM, letting running jobs finish.
Sourcepub async fn run(self) -> Result<()>
pub async fn run(self) -> Result<()>
Reads the process’s own arguments and does what they ask: serve
(the default, as Bootstrap::serve), queue work [--once] [--stop-when-empty] [--queue a,b] (a worker alone) or schedule run [--once] (the ticker alone). The scaffolded main calls this, so
lat queue work and lat schedule run have something to run.
Auto Trait Implementations§
impl !RefUnwindSafe for Bootstrap
impl !Send for Bootstrap
impl !Sync for Bootstrap
impl !UnwindSafe for Bootstrap
impl Freeze for Bootstrap
impl Unpin for Bootstrap
impl UnsafeUnpin for Bootstrap
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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