Skip to main content

SignalClient

Struct SignalClient 

Source
pub struct SignalClient {
    pub sink: Arc<dyn SignalSink>,
    pub runtime: Runtime,
    /* private fields */
}
Expand description

The assembled pipeline: validate -> record -> route -> deliver -> complete. The signal is saved before delivery starts, so it survives a process exit mid-delivery as pending, and each provider’s outcome is saved as soon as it is known. A sink failure is logged and never stops delivery.

Dropping the client waits up to DEFAULT_FLUSH_TIMEOUT for fire-and-forget deliveries; call SignalClient::flush to choose the wait, or when the client lives in a static that is never dropped.

Fields§

§sink: Arc<dyn SignalSink>§runtime: Runtime

Implementations§

Source§

impl SignalClient

Source

pub fn from_config(config: &Config) -> Result<Self, SignalError>

Builds a client from a parsed signal.yaml: registers the configured providers (console always), opens the sink, and starts the runtime that delivery tasks run on. The config is fixed for the client’s lifetime; see SignalClient::from_source for one that reloads.

Source

pub fn from_source( source: &ConfigSource, opts: &LoadOptions, ) -> Result<Self, SignalError>

Loads the config from source and, if opts.refresh is set, keeps re-reading it in the background and applies changes without a restart. A reload that fails to fetch or parse keeps the current config, so a bad edit can’t take alerting down.

Source

pub fn from_sources( sources: &[ConfigSource], opts: &LoadOptions, ) -> Result<Self, SignalError>

SignalClient::from_source for a layered config: sources are merged lowest priority first, along with every file they extends, and any of them changing triggers a reload.

Source

pub fn from_env() -> Result<Self, SignalError>

The discovered config ($SIGNAL_CONFIG, then ./signal.yaml, then the zero-config default), reloaded on the interval in $SIGNAL_CONFIG_REFRESH_SECS.

Source

pub fn pipeline(&self) -> Arc<Pipeline> ⓘ

The routing rules and providers currently in effect.

Source

pub fn notify_async(&self, input: SignalInput)

Fire-and-forget. Blocks the caller only for the local sink write, never on a provider. This is the default an Airflow on_failure_callback should use — a flaky Slack webhook must never add latency or failure risk to the DAG run itself.

Source

pub fn flush(&self, timeout: Duration) -> bool

Waits up to timeout for every SignalClient::notify_async delivery started so far to finish. Returns false if some were still running; those stay recorded as pending. Call it before the process exits.

Source

pub fn notify_sync( &self, input: SignalInput, timeout: Duration, ) -> Result<DeliveryResult, SignalError>

Blocking, bounded by timeout. Caller gets a definitive result. Same pipeline as notify_async — only the blocking behavior differs. On a timeout, providers that already delivered still count, so a fan-out cut short reports Partial rather than Failed.

Trait Implementations§

Source§

impl Drop for SignalClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more