pub struct WebhookSubscription { /* private fields */ }Expand description
Static config for one webhook subscriber, plus convenience methods to register the delivery handler and dispatch events.
Keep one of these per subscription. Cheap to clone.
Implementations§
Source§impl WebhookSubscription
impl WebhookSubscription
pub fn new(target_url: impl Into<String>, secret: impl Into<String>) -> Self
pub fn signature_format(self, fmt: SignatureFormat) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn timeout(self, t: Duration) -> Self
Sourcepub fn retry_status_codes(self, codes: impl IntoIterator<Item = u16>) -> Self
pub fn retry_status_codes(self, codes: impl IntoIterator<Item = u16>) -> Self
Add status codes that should be retried in addition to the defaults (408, 429, 5xx).
Sourcepub async fn register<Q: JobQueue>(queue: &Q)
pub async fn register<Q: JobQueue>(queue: &Q)
Register the delivery Job on queue. Idempotent — call once
per process at startup before Self::dispatch.
Sourcepub async fn dispatch<Q: JobQueue>(
&self,
queue: &Q,
event_name: impl Into<String>,
payload: impl Serialize,
) -> Result<String, JobError>
pub async fn dispatch<Q: JobQueue>( &self, queue: &Q, event_name: impl Into<String>, payload: impl Serialize, ) -> Result<String, JobError>
Build a WebhookEvent and enqueue it. Returns immediately —
delivery happens asynchronously on a worker.
§Errors
Returns the underlying JobError::Queue when the enqueue fails
(DB unavailable, channel closed, payload not serializable).
Trait Implementations§
Source§impl Clone for WebhookSubscription
impl Clone for WebhookSubscription
Source§fn clone(&self) -> WebhookSubscription
fn clone(&self) -> WebhookSubscription
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WebhookSubscription
impl RefUnwindSafe for WebhookSubscription
impl Send for WebhookSubscription
impl Sync for WebhookSubscription
impl Unpin for WebhookSubscription
impl UnsafeUnpin for WebhookSubscription
impl UnwindSafe for WebhookSubscription
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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