pub struct RoadsterAppBuilder<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync = Empty>{ /* private fields */ }Expand description
Builder-style API to build/customize a RoadsterApp.
See https://github.com/roadster-rs/roadster/tree/main/examples/app-builder/src/main.rs for
an example of how to use the RoadsterAppBuilder.
The Cli type parameter is only required when the using a custom CLI.
Implementations§
Source§impl<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync> RoadsterAppBuilder<S, Cli>
impl<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync> RoadsterAppBuilder<S, Cli>
pub fn new() -> Self
Sourcepub fn add_async_config_source(
self,
source: impl AsyncSource + Send + 'static,
) -> Self
pub fn add_async_config_source( self, source: impl AsyncSource + Send + 'static, ) -> Self
Add an async config source (AsyncSource). Useful to load configs/secrets from an
external service, e.g., AWS or GCS secrets manager services.
Sourcepub fn add_async_config_source_provider(
self,
source_provider: impl 'static + Send + Sync + Fn(&Environment) -> RoadsterResult<Box<dyn AsyncSource + Send + Sync>>,
) -> Self
pub fn add_async_config_source_provider( self, source_provider: impl 'static + Send + Sync + Fn(&Environment) -> RoadsterResult<Box<dyn AsyncSource + Send + Sync>>, ) -> Self
Add an async config source (AsyncSource). Useful to load configs/secrets from an
external service, e.g., AWS or GCS secrets manager services.
Sourcepub fn tracing_initializer(
self,
tracing_initializer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<()>,
) -> Self
pub fn tracing_initializer( self, tracing_initializer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<()>, ) -> Self
Provide the logic to initialize tracing for the RoadsterApp.
Sourcepub fn metadata(self, metadata: AppMetadata) -> Self
pub fn metadata(self, metadata: AppMetadata) -> Self
Provide the AppMetadata for the RoadsterApp.
Sourcepub fn metadata_provider(
self,
metadata_provider: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<AppMetadata>,
) -> Self
pub fn metadata_provider( self, metadata_provider: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<AppMetadata>, ) -> Self
Provide the logic to build the AppMetadata for the RoadsterApp.
Sourcepub fn sea_orm_conn_options(self, sea_orm_conn_options: ConnectOptions) -> Self
pub fn sea_orm_conn_options(self, sea_orm_conn_options: ConnectOptions) -> Self
Provide the ConnectOptions for the RoadsterApp.
Sourcepub fn sea_orm_conn_options_provider(
self,
sea_orm_conn_options_provider: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<ConnectOptions>,
) -> Self
pub fn sea_orm_conn_options_provider( self, sea_orm_conn_options_provider: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<ConnectOptions>, ) -> Self
Provide the logic to build the ConnectOptions for the RoadsterApp.
pub fn diesel_pg_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselPgConn, Error>, ) -> Self
pub fn diesel_pg_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselPgConn, Error>>>, ) -> Self
pub fn diesel_mysql_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselMysqlConn, Error>, ) -> Self
pub fn diesel_mysql_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselMysqlConn, Error>>>, ) -> Self
pub fn diesel_sqlite_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselSqliteConn, Error>, ) -> Self
pub fn diesel_sqlite_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselSqliteConn, Error>>>, ) -> Self
pub fn diesel_pg_async_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselPgConnAsync, PoolError>, ) -> Self
pub fn diesel_pg_async_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselPgConnAsync, PoolError>>>, ) -> Self
pub fn diesel_mysql_async_connection_customizer( self, connection_customizer: impl 'static + CustomizeConnection<DieselMysqlConnAsync, PoolError>, ) -> Self
pub fn diesel_mysql_async_connection_customizer_provider( self, connection_customizer: impl 'static + Send + Sync + Fn(&AppConfig) -> RoadsterResult<Box<dyn CustomizeConnection<DieselMysqlConnAsync, PoolError>>>, ) -> Self
Sourcepub fn state_provider(
self,
builder: impl 'static + Send + Sync + Fn(AppContext) -> RoadsterResult<S>,
) -> Self
pub fn state_provider( self, builder: impl 'static + Send + Sync + Fn(AppContext) -> RoadsterResult<S>, ) -> Self
Provide the logic to build the custom state for the RoadsterApp.
Sourcepub fn sea_orm_migrator(
self,
migrator: impl 'static + Sync + MigratorTrait,
) -> Self
pub fn sea_orm_migrator( self, migrator: impl 'static + Sync + MigratorTrait, ) -> Self
Add the diesel migrator sea_orm_migration::MigratorTrait to run on app start up
(if the database.auto-migrate config field is set to true)
Note: SeaORM migrations expect all of the applied migrations to be available to the provided migrator, so only a single SeaORM migrator is allowed.
Sourcepub fn diesel_migrator<C>(
self,
migrator: impl 'static + Send + Sync + MigrationSource<C::Backend>,
) -> Self
pub fn diesel_migrator<C>( self, migrator: impl 'static + Send + Sync + MigrationSource<C::Backend>, ) -> Self
Add the diesel migrator diesel::migration::MigrationSource to run on app start up
(if the database.auto-migrate config field is set to true)
Note: Diesel migrations expect all of the applied migrations to be available to the provided migrator, so only a single Diesel migrator is allowed.
Sourcepub fn add_migrator(self, migrator: impl Migrator<S> + 'static) -> Self
pub fn add_migrator(self, migrator: impl Migrator<S> + 'static) -> Self
Add a Migrator to run on app start up (if the database.auto-migrate config field is
set to true).
Note: SeaORM and Diesel migrations expect all of the applied migrations to be available to the provided migrator, so multiple SeaORM or Diesel migrators should not be provided via this method.
Sourcepub fn add_migrator_provider(
self,
migrator_provider: impl 'static + Send + Sync + Fn(&S) -> RoadsterResult<Box<dyn Migrator<S>>>,
) -> Self
pub fn add_migrator_provider( self, migrator_provider: impl 'static + Send + Sync + Fn(&S) -> RoadsterResult<Box<dyn Migrator<S>>>, ) -> Self
Add a [MigratorProvider] that provides a Migrator to run on app start up
(if the database.auto-migrate config field is set to true).
This is useful compared to Self::add_migrator if the Migrator implementation
needs access to the app state for any reason.
Note: SeaORM and Diesel migrations expect all of the applied migrations to be available to the provided migrator, so multiple SeaORM or Diesel migrators should not be provided via this method.
Sourcepub fn add_lifecycle_handler(
self,
lifecycle_handler: impl 'static + AppLifecycleHandler<RoadsterApp<S, Cli>, S>,
) -> Self
pub fn add_lifecycle_handler( self, lifecycle_handler: impl 'static + AppLifecycleHandler<RoadsterApp<S, Cli>, S>, ) -> Self
Add a AppLifecycleHandler for the RoadsterApp.
This method can be called multiple times to register multiple handlers.
Sourcepub fn add_lifecycle_handler_provider(
self,
lifecycle_handler_provider: impl 'static + Send + Sync + Fn(&mut LifecycleHandlerRegistry<RoadsterApp<S, Cli>, S>, &S) -> RoadsterResult<()>,
) -> Self
pub fn add_lifecycle_handler_provider( self, lifecycle_handler_provider: impl 'static + Send + Sync + Fn(&mut LifecycleHandlerRegistry<RoadsterApp<S, Cli>, S>, &S) -> RoadsterResult<()>, ) -> Self
Provide the logic to register AppLifecycleHandlers for the RoadsterApp.
This method can be called multiple times to register multiple handlers in separate callbacks.
Sourcepub fn add_health_check(self, health_check: impl 'static + HealthCheck) -> Self
pub fn add_health_check(self, health_check: impl 'static + HealthCheck) -> Self
Add a HealthCheck for the RoadsterApp.
This method can be called multiple times to register multiple health checks.
Sourcepub fn add_health_check_provider(
self,
health_check_provider: impl 'static + Send + Sync + Fn(&mut HealthCheckRegistry, &S) -> RoadsterResult<()>,
) -> Self
pub fn add_health_check_provider( self, health_check_provider: impl 'static + Send + Sync + Fn(&mut HealthCheckRegistry, &S) -> RoadsterResult<()>, ) -> Self
Provide the logic to register HealthChecks for the RoadsterApp.
This method can be called multiple times to register multiple health checks in separate callbacks.
Sourcepub fn add_service(
self,
service: impl 'static + AppService<RoadsterApp<S, Cli>, S>,
) -> Self
pub fn add_service( self, service: impl 'static + AppService<RoadsterApp<S, Cli>, S>, ) -> Self
Add a AppService for the RoadsterApp.
This method can be called multiple times to register multiple services.
Sourcepub fn add_service_provider(
self,
service_provider: impl 'static + Send + Sync + for<'a> Fn(&'a mut ServiceRegistry<RoadsterApp<S, Cli>, S>, &'a S) -> Pin<Box<dyn Send + Future<Output = RoadsterResult<()>> + 'a>>,
) -> Self
pub fn add_service_provider( self, service_provider: impl 'static + Send + Sync + for<'a> Fn(&'a mut ServiceRegistry<RoadsterApp<S, Cli>, S>, &'a S) -> Pin<Box<dyn Send + Future<Output = RoadsterResult<()>> + 'a>>, ) -> Self
Provide the logic to register AppServices for the RoadsterApp.
This method can be called multiple times to register multiple services in separate callbacks.
Sourcepub fn graceful_shutdown_signal_provider(
self,
graceful_shutdown_signal_provider: impl 'static + Send + Sync + Fn(&S) -> Pin<Box<dyn Send + Future<Output = ()>>>,
) -> Self
pub fn graceful_shutdown_signal_provider( self, graceful_shutdown_signal_provider: impl 'static + Send + Sync + Fn(&S) -> Pin<Box<dyn Send + Future<Output = ()>>>, ) -> Self
Provide a custom signal to listen for in order to shutdown the RoadsterApp.
Sourcepub fn build(self) -> RoadsterApp<S, Cli>
pub fn build(self) -> RoadsterApp<S, Cli>
Build the RoadsterApp from this RoadsterAppBuilder.
Trait Implementations§
Source§impl<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync> Default for RoadsterAppBuilder<S, Cli>
impl<S, Cli: 'static + Args + RunCommand<RoadsterApp<S, Cli>, S> + Send + Sync> Default for RoadsterAppBuilder<S, Cli>
Auto Trait Implementations§
impl<S, Cli> Freeze for RoadsterAppBuilder<S, Cli>
impl<S, Cli = Empty> !RefUnwindSafe for RoadsterAppBuilder<S, Cli>
impl<S, Cli> Send for RoadsterAppBuilder<S, Cli>
impl<S, Cli> Sync for RoadsterAppBuilder<S, Cli>
impl<S, Cli> Unpin for RoadsterAppBuilder<S, Cli>
impl<S, Cli = Empty> !UnwindSafe for RoadsterAppBuilder<S, Cli>
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnection>::ExecuteFuture<'conn, 'query>
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnection,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnection,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Source§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>, fn(_: Self::Stream<'conn>) -> Map<StreamFuture<Pin<Box<Self::Stream<'conn>>>>, fn(_: (Option<Result<U, Error>>, Pin<Box<Self::Stream<'conn>>>)) -> Result<U, Error>>>
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>, fn(_: Self::Stream<'conn>) -> TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec with the affected rows. Read more