pub struct Hub { /* private fields */ }Expand description
The core and the workers’ outgoing streams.
Implementations§
Source§impl Hub
impl Hub
Sourcepub fn new(core: MasterCore) -> Self
pub fn new(core: MasterCore) -> Self
A hub over core, with the system clock.
Sourcepub fn with_clock(core: MasterCore, clock: fn() -> Timestamp) -> Self
pub fn with_clock(core: MasterCore, clock: fn() -> Timestamp) -> Self
A hub over core with another clock (tests).
Sourcepub const fn with_listen_retry(self, period: Duration) -> Self
pub const fn with_listen_retry(self, period: Duration) -> Self
The hub trying to listen for commands again every period while its loop runs without
notifications (starting them failed: the database too slow to check for a pooler, or
unreachable), polling meanwhile; it stops trying once they start, or once they are found
off or behind a pooler.
Sourcepub const fn with_epoch(self, epoch: i64) -> Self
pub const fn with_epoch(self, epoch: i64) -> Self
The hub stamping epoch, its lease’s, on every message (decision 444).
Sourcepub fn with_problems(self, problems: Problems) -> Self
pub fn with_problems(self, problems: Problems) -> Self
The hub reporting its problems to problems (its heartbeat writes them).
Sourcepub const fn with_refresh_limit(self, limit: Duration) -> Self
pub const fn with_refresh_limit(self, limit: Duration) -> Self
The hub abandoning a gauge refresh that takes longer than limit (it only reads, so
abandoning it is safe; a tick is never abandoned: see archive/PROJECT.md, Observability).
Sourcepub fn leading(&self) -> Receiver<bool>
pub fn leading(&self) -> Receiver<bool>
Whether this master leads: false while paused (its lease not renewed) or after another took it over; readiness follows it (B165).
Sourcepub fn beat(&self) -> Beat
pub fn beat(&self) -> Beat
When the loop last turned: every tick, and at least every ALIVE_INTERVAL while it
waits, never while a tick is stuck.
Sourcepub async fn run_sender(
&self,
sender: Sender,
poll: Duration,
stop: impl Future<Output = ()>,
)
pub async fn run_sender( &self, sender: Sender, poll: Duration, stop: impl Future<Output = ()>, )
Delivers the outbox through sender while this master leads (decision 410): a pass
every poll, at once again after a full one, until stop completes. A failing pass is
logged; the next one goes on.
Sourcepub async fn run_retention(
&self,
settings: RetentionSettings,
stop: impl Future<Output = ()>,
)
pub async fn run_retention( &self, settings: RetentionSettings, stop: impl Future<Output = ()>, )
Deletes what [retention] no longer keeps while this master leads (decisions
430-435): a pass at once, then one every settings.interval, until stop completes. A
failing pass is logged; the next one goes on.
Sourcepub async fn run_samples(
&self,
settings: SampleSettings,
__arg2: (String, bool),
stop: impl Future<Output = ()>,
)
pub async fn run_samples( &self, settings: SampleSettings, __arg2: (String, bool), stop: impl Future<Output = ()>, )
Samples each process a minute while this master leads (decision 464): its masters and
workers, one row per process (process_id, this master’s own, gets its webserver role
with with_webserver), the rollups and deletes once a window closes, until stop
completes. A failing pass is logged; the next one goes on.
Sourcepub async fn refresh_gauges(&self)
pub async fn refresh_gauges(&self)
Refreshes the gauges taken from the database; a failure is logged (the gauges keep their last values).
Sourcepub fn core(&self) -> Arc<Mutex<MasterCore>> ⓘ
pub fn core(&self) -> Arc<Mutex<MasterCore>> ⓘ
The core, for status and tests.
Sourcepub fn service(&self) -> MasterServer<Self>
pub fn service(&self) -> MasterServer<Self>
The gRPC service for a tonic server.
Sourcepub async fn restore(&self) -> Result<usize, CoreError>
pub async fn restore(&self) -> Result<usize, CoreError>
Reads the worker registry back (see MasterCore::restore) at the hub’s clock, the
one its lease checks use.
§Errors
The core’s failure.
Sourcepub async fn tick(&self) -> Result<(), CoreError>
pub async fn tick(&self) -> Result<(), CoreError>
One tick of the master’s loop, its messages delivered; its probe looks no time ahead.
§Errors
The core’s failure (the next tick goes on).
Sourcepub async fn tick_ahead(&self, ahead: Duration) -> Result<(), CoreError>
pub async fn tick_ahead(&self, ahead: Duration) -> Result<(), CoreError>
As Self::tick, its probe looking ahead (the loop’s tick interval: what comes due
before the next tick is found, so the round’s parts share one probe, decision 485).
§Errors
The core’s failure (the next tick goes on).
Sourcepub async fn run(
&self,
interval: Duration,
notifications: Option<CommandNotifications>,
stop: impl Future<Output = ()>,
)
pub async fn run( &self, interval: Duration, notifications: Option<CommandNotifications>, stop: impl Future<Output = ()>, )
Runs the master’s loop: a tick every interval until stop completes, and at once when
a new command is announced (notifications, Postgres; notifications that arrived
meanwhile are taken by the same tick, and the tick interval starts again after it). A
failing tick is logged; the next one goes on. When notifications fail (the database is
unreachable), they are tried again after NOTIFICATION_RETRY; polling goes on.
Sourcepub async fn run_leading(
&self,
interval: Duration,
notifications: Option<CommandNotifications>,
leadership: Leadership,
stop: impl Future<Output = ()>,
) -> Result<(), LeaseLost>
pub async fn run_leading( &self, interval: Duration, notifications: Option<CommandNotifications>, leadership: Leadership, stop: impl Future<Output = ()>, ) -> Result<(), LeaseLost>
As Self::run, leading by leadership’s lease (see crate::lease): renewed every
third of its period by a task of its own (a long round doesn’t hold renewals up); while
it isn’t fresh enough the master pauses (no rounds, worker messages wait) and resumes
once renewed; it is given up when stop completes. The hub’s core must write through
Leadership::fenced_db.
§Errors
LeaseLost when another master took it over.
Sourcepub async fn close_streams(&self)
pub async fn close_streams(&self)
Ends every worker’s stream with UNAVAILABLE, for the master to stop: tonic’s graceful
shutdown waits for open calls, which a worker’s stream never ends by itself, and each
worker connects again, to the master that leads (B200).
Trait Implementations§
Source§impl Master for Hub
impl Master for Hub
Source§type ControlStream = ReceiverStream<Result<MasterMessage, Status>>
type ControlStream = ReceiverStream<Result<MasterMessage, Status>>
Source§type FetchInputsStream = ReceiverStream<Result<InputChunk, Status>>
type FetchInputsStream = ReceiverStream<Result<InputChunk, Status>>
Source§fn control<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<WorkerMessage>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ControlStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn control<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<WorkerMessage>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ControlStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn upload_parse_result<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<ParseResultPart>>,
) -> Pin<Box<dyn Future<Output = Result<Response<ParseResultAck>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upload_parse_result<'life0, 'async_trait>(
&'life0 self,
request: Request<Streaming<ParseResultPart>>,
) -> Pin<Box<dyn Future<Output = Result<Response<ParseResultAck>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn fetch_inputs<'life0, 'async_trait>(
&'life0 self,
request: Request<FetchInputsRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<Self::FetchInputsStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fetch_inputs<'life0, 'async_trait>(
&'life0 self,
request: Request<FetchInputsRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<Self::FetchInputsStream>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for Hub
impl !UnwindSafe for Hub
impl Freeze for Hub
impl Send for Hub
impl Sync for Hub
impl Unpin for Hub
impl UnsafeUnpin for Hub
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
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);