pub struct ApiState {Show 16 fields
pub db: Database,
pub version: SchedrVersion,
pub version_text: &'static str,
pub auth: Auth,
pub clock: fn() -> Timestamp,
pub logs: Arc<dyn LogSource>,
pub metrics: ApiMetrics,
pub connection_test_timeout: Duration,
pub heartbeat_interval: Duration,
pub feed: Feed,
pub max_event_size: usize,
pub node: Arc<NodeView>,
pub usage: fn() -> Option<NodeUsage>,
pub series: Arc<SeriesCache>,
pub flow: Arc<FlowCache>,
pub limits: ApiLimits,
}Expand description
The webserver’s shared state.
Fields§
§db: DatabaseThe database (read directly; actions are command rows).
version: SchedrVersionThe server’s version, for the version check.
version_text: &'static strThe server’s full version, sent in Schedr-Server-Version.
auth: AuthWho the user is ([webserver.auth], and the UI’s proof: see crate::auth).
clock: fn() -> TimestampThe clock (replaced in tests).
logs: Arc<dyn LogSource>Where task logs come from (the workers).
metrics: ApiMetricsThe webserver’s metrics.
connection_test_timeout: DurationHow long a connection test may take when its request doesn’t say.
heartbeat_interval: DurationThe workers’ heartbeat interval: a poke trigger whose last call ended longer ago than
three times its every plus this is stuck.
feed: FeedWhat changed, for GET /api/v1/changes.
max_event_size: usizeThe largest posted event’s data ([events] max_size).
node: Arc<NodeView>This webserver as a node of its deployment (GET /api/v1/deployment), its
configuration masked.
usage: fn() -> Option<NodeUsage>What this process uses now (decision 463); none by default (the binary reads /proc).
series: Arc<SeriesCache>The Metrics endpoints’ final buckets, kept between requests.
flow: Arc<FlowCache>The Metrics page’s throughput and start latency’s final buckets, kept the same way.
limits: ApiLimitsHow far its reads reach and what they allow (decision 493).
Implementations§
Source§impl ApiState
impl ApiState
Sourcepub fn new(db: Database, identity_header: Option<String>) -> Self
pub fn new(db: Database, identity_header: Option<String>) -> Self
State over db for this build of schedr, with the system clock, reading logs from
workers over plain HTTP (see Self::with_logs).
Sourcepub fn with_limits(self, limits: ApiLimits, cache: CacheLimits) -> Self
pub fn with_limits(self, limits: ApiLimits, cache: CacheLimits) -> Self
This state with the webserver’s limits, its Metrics cache’s included (decision 493).
Sourcepub fn with_connection_test_timeout(self, timeout: Duration) -> Self
pub fn with_connection_test_timeout(self, timeout: Duration) -> Self
This state, giving a connection test timeout when its request doesn’t say.
Sourcepub fn with_heartbeat_interval(self, interval: Duration) -> Self
pub fn with_heartbeat_interval(self, interval: Duration) -> Self
This state, judging a poke trigger stuck with interval, the workers’ heartbeat.
Sourcepub fn with_max_event_size(self, bytes: usize) -> Self
pub fn with_max_event_size(self, bytes: usize) -> Self
This state, refusing posted events whose data is over bytes ([events] max_size).
Sourcepub fn with_usage(self, usage: fn() -> Option<NodeUsage>) -> Self
pub fn with_usage(self, usage: fn() -> Option<NodeUsage>) -> Self
This state reading what its process uses with usage (decision 463).
Sourcepub fn with_node(self, node: NodeView) -> Self
pub fn with_node(self, node: NodeView) -> Self
This state’s webserver shown as node (its configuration masked by the caller).
Sourcepub fn with_metrics(self, metrics: ApiMetrics) -> Self
pub fn with_metrics(self, metrics: ApiMetrics) -> Self
This state recording its metrics in metrics (registered by the caller).
Sourcepub fn with_refresh(self, interval: Duration) -> Self
pub fn with_refresh(self, interval: Duration) -> Self
This state’s live pages refreshed every interval when the database’s changes can’t be
followed (refresh_interval).
Sourcepub fn with_event_timings(self, timings: EventTimings) -> Self
pub fn with_event_timings(self, timings: EventTimings) -> Self
This state following the database’s changes as timings say.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ApiState
impl !RefUnwindSafe for ApiState
impl !UnwindSafe for ApiState
impl Send for ApiState
impl Sync for ApiState
impl Unpin for ApiState
impl UnsafeUnpin for ApiState
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> ⓘ
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);