pub struct AtrgApp { /* private fields */ }Expand description
The application builder. Accumulates user routers and configuration,
then boots the full server when AtrgApp::run is called.
Implementations§
Source§impl AtrgApp
impl AtrgApp
Sourcepub fn mount(self, router: Router<AppState>) -> Self
pub fn mount(self, router: Router<AppState>) -> Self
Mount an additional [axum::Router] into the application.
Routes are merged, so multiple calls to mount accumulate routes.
Sourcepub fn with_auth_routes(self, router: Router<AppState>) -> Self
pub fn with_auth_routes(self, router: Router<AppState>) -> Self
Sourcepub fn with_cleanup_task<F>(self, f: F) -> Self
pub fn with_cleanup_task<F>(self, f: F) -> Self
Register a background cleanup task that is spawned after the server starts. Typically used for periodic session / OAuth-state expiry.
The callback receives the [SqlitePool] and is expected to call
tokio::spawn internally.
Sourcepub fn on_event<F, Fut>(self, handler: F) -> Self
pub fn on_event<F, Fut>(self, handler: F) -> Self
Register a Jetstream event handler.
The handler is called for every event received from the Jetstream
firehose. It is spawned as a background task inside AtrgApp::run
when [jetstream] is present in atrg.toml.
Sourcepub fn on_firehose_event<F, Fut>(self, handler: F) -> Self
pub fn on_firehose_event<F, Fut>(self, handler: F) -> Self
Register a firehose event handler.
The handler is called for every event received from the AT Protocol
relay firehose (com.atproto.sync.subscribeRepos). It is spawned as
a background task inside AtrgApp::run when [firehose] is present
in atrg.toml.
Sourcepub fn with_feed_generator(self, feed_router: Router<AppState>) -> Self
pub fn with_feed_generator(self, feed_router: Router<AppState>) -> Self
Sourcepub fn with_labeler(self, labeler_router: Router<AppState>) -> Self
pub fn with_labeler(self, labeler_router: Router<AppState>) -> Self
Sourcepub async fn run(self) -> Result<()>
pub async fn run(self) -> Result<()>
Boot the server.
This is the only async entry point. It:
- Initialises tracing (respects
RUST_LOG). - Loads
atrg.toml(or$ATRG_CONFIG). - Connects to SQLite and runs migrations.
- Builds
AppState(including the identity resolver). - Assembles the Axum router with CORS, tracing, and a JSON 404 fallback.
- Spawns optional cleanup tasks.
- Binds a TCP listener and serves.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AtrgApp
impl !RefUnwindSafe for AtrgApp
impl Send for AtrgApp
impl !Sync for AtrgApp
impl Unpin for AtrgApp
impl UnsafeUnpin for AtrgApp
impl !UnwindSafe for AtrgApp
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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