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: RuntimeImplementations§
Source§impl SignalClient
impl SignalClient
Sourcepub fn from_config(config: &Config) -> Result<Self, SignalError>
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.
Sourcepub fn from_source(
source: &ConfigSource,
opts: &LoadOptions,
) -> Result<Self, SignalError>
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.
Sourcepub fn from_sources(
sources: &[ConfigSource],
opts: &LoadOptions,
) -> Result<Self, SignalError>
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.
Sourcepub fn from_env() -> Result<Self, SignalError>
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.
Sourcepub fn notify_async(&self, input: SignalInput)
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.
Sourcepub fn flush(&self, timeout: Duration) -> bool
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.
Sourcepub fn notify_sync(
&self,
input: SignalInput,
timeout: Duration,
) -> Result<DeliveryResult, SignalError>
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.