pub struct HttpWebhookSender { /* private fields */ }Expand description
HTTP webhook sender with retry logic
§Example
use reinhardt_tasks::webhook::{HttpWebhookSender, WebhookConfig, RetryConfig};
use std::time::Duration;
let config = WebhookConfig {
url: "https://example.com/webhook".to_string(),
method: "POST".to_string(),
headers: Default::default(),
timeout: Duration::from_secs(5),
retry_config: RetryConfig::default(),
};
let sender = HttpWebhookSender::new(config);Implementations§
Source§impl HttpWebhookSender
impl HttpWebhookSender
Sourcepub fn new(config: WebhookConfig) -> Self
pub fn new(config: WebhookConfig) -> Self
Create a new HTTP webhook sender
§Example
use reinhardt_tasks::webhook::{HttpWebhookSender, WebhookConfig};
let sender = HttpWebhookSender::new(WebhookConfig::default());Sourcepub fn calculate_backoff(&self, retry_count: u32) -> Duration
pub fn calculate_backoff(&self, retry_count: u32) -> Duration
Calculate backoff duration with exponential backoff and jitter
§Example
use reinhardt_tasks::webhook::{HttpWebhookSender, WebhookConfig, RetryConfig};
use std::time::Duration;
let config = WebhookConfig {
url: "https://example.com".to_string(),
method: "POST".to_string(),
headers: Default::default(),
timeout: Duration::from_secs(5),
retry_config: RetryConfig::default(),
};
let sender = HttpWebhookSender::new(config);
let backoff = sender.calculate_backoff(2);
assert!(backoff > Duration::from_millis(0));Trait Implementations§
Source§impl WebhookSender for HttpWebhookSender
impl WebhookSender for HttpWebhookSender
Auto Trait Implementations§
impl Freeze for HttpWebhookSender
impl !RefUnwindSafe for HttpWebhookSender
impl Send for HttpWebhookSender
impl Sync for HttpWebhookSender
impl Unpin for HttpWebhookSender
impl UnsafeUnpin for HttpWebhookSender
impl !UnwindSafe for HttpWebhookSender
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