pub struct MasterCore { /* private fields */ }Expand description
The master’s state between messages.
Implementations§
Source§impl MasterCore
impl MasterCore
Sourcepub async fn plan_api_call(
&mut self,
worker_id: &str,
call: ApiCall,
now: Timestamp,
) -> Result<ApiCallPlan, CoreError>
pub async fn plan_api_call( &mut self, worker_id: &str, call: ApiCall, now: Timestamp, ) -> Result<ApiCallPlan, CoreError>
A task’s request through its worker: to run as the task, if the worker holds that attempt (or trigger) open and the route is on the list; refused otherwise.
§Errors
A database failure.
Source§impl MasterCore
impl MasterCore
Sourcepub fn with_steady(self, steady: Steady) -> Self
pub fn with_steady(self, steady: Steady) -> Self
The master deciding liveness on steady (production: crate::clock::monotonic, set
by crate::service::Hub::new; tests: the times they pass).
Sourcepub fn with_wall(self, wall: fn() -> Timestamp) -> Self
pub fn with_wall(self, wall: fn() -> Timestamp) -> Self
The wall clock read with master time where the two are compared (M5.1m; production:
[Timestamp::now], set by crate::service::Hub::new; tests: the times they pass).
Sourcepub const fn steady_clock(&self) -> Steady
pub const fn steady_clock(&self) -> Steady
How it reads master time (see crate::clock).
Sourcepub fn with_notifications(self, notifications: Arc<Notifications>) -> Self
pub fn with_notifications(self, notifications: Arc<Notifications>) -> Self
The master sending notifications as notifications says ([notifications]): what
runs, tasks and triggers queue, and the checks on DAGs’ notify=.
Sourcepub fn with_task_api(self, api: Arc<dyn TaskApi>) -> Self
pub fn with_task_api(self, api: Arc<dyn TaskApi>) -> Self
The master serving tasks’ REST requests through api (M4.11h).
Sourcepub fn with_metrics(self, metrics: MasterMetrics) -> Self
pub fn with_metrics(self, metrics: MasterMetrics) -> Self
The master recording its metrics in metrics (registered by the caller).
Sourcepub const fn metrics(&self) -> &MasterMetrics
pub const fn metrics(&self) -> &MasterMetrics
Its metrics.
Sourcepub const fn dispatcher(&self) -> &Dispatcher
pub const fn dispatcher(&self) -> &Dispatcher
The dispatcher (its workers, for status and tests).
Sourcepub fn arrivals(&self) -> Arrivals
pub fn arrivals(&self) -> Arrivals
When each worker’s latest message arrived, for the streams’ readers to record.
Sourcepub async fn restore(&mut self, now: Timestamp) -> Result<usize, CoreError>
pub async fn restore(&mut self, now: Timestamp) -> Result<usize, CoreError>
Reads the worker registry back at start: every worker not gone counts as disconnected
from now plus Settings::takeover_wait, so its lease starts from zero once a
deposed leader can no longer answer it (decision 444; master downtime doesn’t count
against workers) and one that never comes back is lost, its attempts with it. Returns
how many workers were restored.
§Errors
CoreError::Db if the database fails.
Sourcepub async fn register(
&mut self,
register: &Register,
now: Timestamp,
) -> Result<(Registered, Vec<Outgoing>), CoreError>
pub async fn register( &mut self, register: &Register, now: Timestamp, ) -> Result<(Registered, Vec<Outgoing>), CoreError>
A worker registers (the first message on its stream). Returns Registered, with a
decision per journal entry, and the parse jobs for its roots.
§Errors
CoreError::Refused for an incompatible protocol version or a worker ID that already
has a live stream; CoreError::Db / CoreError::Dispatch if the database fails.
Sourcepub async fn handle(
&mut self,
worker_id: &str,
message: Message,
now: Timestamp,
) -> Result<Vec<Outgoing>, CoreError>
pub async fn handle( &mut self, worker_id: &str, message: Message, now: Timestamp, ) -> Result<Vec<Outgoing>, CoreError>
A message on a registered worker’s stream.
§Errors
CoreError::BadMessage for a message that doesn’t fit (a second Register, unknown
enum values), or a database failure.
Sourcepub async fn disconnected(
&mut self,
worker_id: &str,
now: Timestamp,
) -> Result<(), CoreError>
pub async fn disconnected( &mut self, worker_id: &str, now: Timestamp, ) -> Result<(), CoreError>
A worker’s stream ended: it may reconnect (same incarnation, tasks still running) within the lease timeout, or it is lost at the next tick after that.
§Errors
CoreError::Db if the registry can’t be written.
Sourcepub async fn tick(&mut self, now: Timestamp) -> Result<Vec<Outgoing>, CoreError>
pub async fn tick(&mut self, now: Timestamp) -> Result<Vec<Outgoing>, CoreError>
One pass of the master’s loop: commands, the scheduler, dispatching, parse jobs past their timeout, and workers past their lease.
§Errors
The first failure; what was done before it stays done, and the next tick goes on.
Sourcepub async fn tick_partial(
&mut self,
now: Timestamp,
) -> (Vec<Outgoing>, Result<(), CoreError>)
pub async fn tick_partial( &mut self, now: Timestamp, ) -> (Vec<Outgoing>, Result<(), CoreError>)
As Self::tick, with the messages built before a failure: each is built after the
write it stands for is stored, so they are delivered whatever comes after (B7: a cancel
dropped with its failed round was sent again only when the worker reconnected).
Sourcepub async fn round_part(
&mut self,
part: RoundPart,
now: Timestamp,
outgoing: &mut Vec<Outgoing>,
) -> Result<(), CoreError>
pub async fn round_part( &mut self, part: RoundPart, now: Timestamp, outgoing: &mut Vec<Outgoing>, ) -> Result<(), CoreError>
One part of a round, its messages into outgoing (each built after the write it stands
for is stored). The service takes the core’s lock for each part on its own, so a
worker’s turn gets in between them (decision 469); Self::tick runs them all.
§Errors
The part’s failure: the round’s later parts wait for the next round.
Sourcepub async fn commands_to_apply(
&mut self,
outgoing: &mut Vec<Outgoing>,
now: Timestamp,
) -> Result<Vec<PendingCommand>, CoreError>
pub async fn commands_to_apply( &mut self, outgoing: &mut Vec<Outgoing>, now: Timestamp, ) -> Result<Vec<PendingCommand>, CoreError>
Sourcepub async fn apply_command(
&mut self,
pending: PendingCommand,
outgoing: &mut Vec<Outgoing>,
now: Timestamp,
) -> Result<(), CoreError>
pub async fn apply_command( &mut self, pending: PendingCommand, outgoing: &mut Vec<Outgoing>, now: Timestamp, ) -> Result<(), CoreError>
One command applied in its own transaction (decision 483), with its follow-ups: the connection jobs it sent timed, a drain’s or resume’s parse jobs moved. What a failed command kept (a commit whose answer was lost) gets its follow-ups too.
§Errors
CoreError if the database fails: the command stays pending, the round’s later ones
wait for the next round.
Sourcepub async fn commands_done(
&mut self,
outgoing: &mut Vec<Outgoing>,
now: Timestamp,
)
pub async fn commands_done( &mut self, outgoing: &mut Vec<Outgoing>, now: Timestamp, )
The commands part’s end: overdue connection jobs marked lost, and the resumes whose follow-up failed tried again (B99), whether or not a command failed.
Sourcepub async fn upload(
&mut self,
result: ParseResult,
now: Timestamp,
) -> Result<(), CoreError>
pub async fn upload( &mut self, result: ParseResult, now: Timestamp, ) -> Result<(), CoreError>
A worker uploads a parse result (unary call).
§Errors
CoreError::BadMessage for a result missing its root or with DAG JSON that doesn’t
read; a database failure.
Sourcepub async fn inputs(
&self,
attempt_id: &str,
) -> Result<Option<Vec<u8>>, CoreError>
pub async fn inputs( &self, attempt_id: &str, ) -> Result<Option<Vec<u8>>, CoreError>
An open attempt’s inputs as JSON (FetchInputs); None for an unknown or ended one.
§Errors
CoreError::Dispatch if the database fails.
Sourcepub async fn handle_group(
&mut self,
worker_id: &str,
group: Group,
now: Timestamp,
) -> Result<Vec<Outgoing>, Group>
pub async fn handle_group( &mut self, worker_id: &str, group: Group, now: Timestamp, ) -> Result<Vec<Outgoing>, Group>
A turn’s Starteds, then its Finisheds (M4B.3, decision 397): one transaction, one
lease check and one commit, with one memory snapshot for the group (B48). Counts, wakes
and arrivals only once it is stored. A commit cut off is read back once, by the last
message: the group lands whole or not at all.
§Errors
The group handed back, its memory put back and nothing of it counted, when it failed (any message’s error, the lease, the commit): the caller handles its messages one by one, which decides each one’s fate as before.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MasterCore
impl !UnwindSafe for MasterCore
impl Freeze for MasterCore
impl Send for MasterCore
impl Sync for MasterCore
impl Unpin for MasterCore
impl UnsafeUnpin for MasterCore
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<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);