pub struct WebhookSubscriber { /* private fields */ }Expand description
Subscriber that POSTs the event as JSON to a webhook URL.
Retries failed deliveries with exponential backoff (up to 3 attempts, 5 s timeout per attempt). The HTTP client is created once and reused.
When a signing secret is provided via WebhookSubscriber::with_signing_secret,
every outbound request includes an X-Signature-256 header whose value
is sha256=<hex-encoded HMAC-SHA256>, computed over the raw JSON body.
This lets the receiver verify payload authenticity.
Event type filtering is handled by the
EventPublisher at subscription time – this
subscriber receives only events that already passed the filter.
§Examples
use ironflow_engine::notify::{Event, EventPublisher, WebhookSubscriber};
let mut publisher = EventPublisher::new();
// Without signature
publisher.subscribe(
WebhookSubscriber::new("https://hooks.example.com/events"),
&[Event::RUN_STATUS_CHANGED, Event::STEP_FAILED],
);
// With HMAC-SHA256 signature
publisher.subscribe(
WebhookSubscriber::with_signing_secret(
"https://hooks.example.com/signed",
"my-webhook-secret",
),
Event::ALL,
);Implementations§
Source§impl WebhookSubscriber
impl WebhookSubscriber
Sourcepub fn new(url: &str) -> Self
pub fn new(url: &str) -> Self
Create a new webhook subscriber targeting the given URL.
Uses the default RetryConfig (3 retries, 5 s timeout, 500 ms
base backoff). No outbound signature is added.
§Panics
Panics if the HTTP client cannot be built (TLS backend unavailable).
§Examples
use ironflow_engine::notify::WebhookSubscriber;
let subscriber = WebhookSubscriber::new("https://example.com/hook");
assert_eq!(subscriber.url(), "https://example.com/hook");
assert!(subscriber.signing_secret().is_none());Sourcepub fn with_retry_config(url: &str, retry_config: RetryConfig) -> Self
pub fn with_retry_config(url: &str, retry_config: RetryConfig) -> Self
Create a webhook subscriber with a custom retry configuration.
No outbound signature is added.
§Panics
Panics if the HTTP client cannot be built (TLS backend unavailable).
§Examples
use ironflow_engine::notify::{RetryConfig, WebhookSubscriber};
let config = RetryConfig::new(
5,
std::time::Duration::from_secs(10),
std::time::Duration::from_secs(1),
);
let subscriber = WebhookSubscriber::with_retry_config("https://example.com/hook", config);Sourcepub fn with_signing_secret(url: &str, secret: &str) -> Self
pub fn with_signing_secret(url: &str, secret: &str) -> Self
Create a webhook subscriber that signs outbound payloads with HMAC-SHA256.
Each request will include an X-Signature-256 header containing
sha256=<hex-encoded digest>, computed over the raw JSON body.
Uses the default RetryConfig.
§Panics
Panics if the HTTP client cannot be built (TLS backend unavailable).
§Examples
use ironflow_engine::notify::WebhookSubscriber;
let subscriber = WebhookSubscriber::with_signing_secret(
"https://example.com/hook",
"my-secret",
);
assert!(subscriber.signing_secret().is_some());Sourcepub fn with_signing_secret_and_retry(
url: &str,
secret: &str,
retry_config: RetryConfig,
) -> Self
pub fn with_signing_secret_and_retry( url: &str, secret: &str, retry_config: RetryConfig, ) -> Self
Create a webhook subscriber with HMAC-SHA256 signing and custom retry config.
§Panics
Panics if the HTTP client cannot be built (TLS backend unavailable).
§Examples
use ironflow_engine::notify::{RetryConfig, WebhookSubscriber};
let config = RetryConfig::new(
5,
std::time::Duration::from_secs(10),
std::time::Duration::from_secs(1),
);
let subscriber = WebhookSubscriber::with_signing_secret_and_retry(
"https://example.com/hook",
"my-secret",
config,
);Sourcepub fn signing_secret(&self) -> Option<&str>
pub fn signing_secret(&self) -> Option<&str>
Returns the signing secret, if configured.