pub struct Hydrant {
pub crawler: CrawlerHandle,
pub firehose: FirehoseHandle,
pub backfill: BackfillHandle,
pub filter: FilterControl,
pub repos: ReposControl,
pub db: DbControl,
pub backlinks: BacklinksControl,
/* private fields */
}Expand description
the top-level handle to a hydrant instance.
Hydrant is cheaply cloneable. all sub-handles share the same underlying state.
construct it via Hydrant::new or Hydrant::from_env, configure the filter
and repos as needed, then call Hydrant::run to start all background components.
§example
use hydrant::control::Hydrant;
#[tokio::main]
async fn main() -> miette::Result<()> {
let hydrant = Hydrant::from_env().await?;
tokio::select! {
r = hydrant.run()? => r,
r = hydrant.serve(3000) => r,
}
}Fields§
§crawler: CrawlerHandle§firehose: FirehoseHandle§backfill: BackfillHandle§filter: FilterControl§repos: ReposControl§db: DbControl§backlinks: BacklinksControlImplementations§
Source§impl Hydrant
impl Hydrant
Sourcepub async fn new(config: Config) -> Result<Self>
pub async fn new(config: Config) -> Result<Self>
open the database and configure hydrant from config.
this sets up the database, applies any filter configuration from config, and
initializes all sub-handles. no background tasks are started yet: call
run to start all components and drive the instance.
Sourcepub async fn from_env() -> Result<Self>
pub async fn from_env() -> Result<Self>
reads config from environment variables and calls Hydrant::new.
Sourcepub fn run(&self) -> Result<impl Future<Output = Result<()>>>
pub fn run(&self) -> Result<impl Future<Output = Result<()>>>
start all background components and return a future that resolves when any fatal component exits.
starts the backfill worker, firehose ingestors, crawler, and worker thread.
resolves with Ok(()) if a fatal component exits cleanly, or Err(e) if it
fails. intended for use in tokio::select! alongside serve.
returns an error if called more than once on the same Hydrant instance.
Sourcepub fn subscribe(&self, cursor: Option<u64>) -> EventStream
pub fn subscribe(&self, cursor: Option<u64>) -> EventStream
subscribe to the ordered event stream.
returns an EventStream that implements [futures::Stream].
- if
cursorisNone, streaming starts from the current head (live tail only). - if
cursorisSome(id), all persistedrecordevents from that ID onward are replayed first, then live events follow seamlessly.
identity and account events are ephemeral and are never replayed from a cursor -
only live occurrences are delivered. use ReposControl::get to fetch current
identity/account state for a specific DID.
multiple concurrent subscribers each receive a full independent copy of the stream.
the stream ends when the EventStream is dropped.
Sourcepub async fn stats(&self) -> Result<StatsResponse>
pub async fn stats(&self) -> Result<StatsResponse>
return database counts and on-disk sizes for all keyspaces.
counts include: repos, pending, resync, records, blocks, events,
error_ratelimited, error_transport, error_generic.
sizes are in bytes, reported per keyspace.
Sourcepub fn serve(&self, port: u16) -> impl Future<Output = Result<()>>
pub fn serve(&self, port: u16) -> impl Future<Output = Result<()>>
returns a future that runs the HTTP management API server on 0.0.0.0:{port}.
the server exposes all management endpoints (/filter, /repos, /ingestion,
/stream, /stats, /db/*, /xrpc/*). it runs indefinitely and resolves
only on error.
intended for tokio::spawn or inclusion in a select! / task list. the clone
of self is deferred until the future is first polled.
to disable the HTTP API entirely, simply don’t call this method.
Sourcepub fn serve_debug(&self, port: u16) -> impl Future<Output = Result<()>>
pub fn serve_debug(&self, port: u16) -> impl Future<Output = Result<()>>
returns a future that runs the debug HTTP API server on 127.0.0.1:{port}.
exposes internal inspection endpoints (/debug/get, /debug/iter, etc.)
that are not safe to expose publicly. binds only to loopback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hydrant
impl !RefUnwindSafe for Hydrant
impl Send for Hydrant
impl Sync for Hydrant
impl Unpin for Hydrant
impl !UnwindSafe for Hydrant
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more