feat(webhooks): implement automatic retries for failed webhook deliveries using scheduler (#3842)

This commit is contained in:
Sanchith Hegde
2024-03-04 12:01:02 +05:30
committed by GitHub
parent fee0663d66
commit 5bb67c7dcc
27 changed files with 965 additions and 215 deletions

View File

@ -3,7 +3,7 @@ use common_utils::{crypto::SignMessage, ext_traits::Encode};
use error_stack::ResultExt;
use serde::Serialize;
use crate::{core::errors, headers, services::request::Maskable};
use crate::{core::errors, headers, services::request::Maskable, types::storage::enums};
pub trait OutgoingWebhookType:
Serialize + From<webhooks::OutgoingWebhook> + Sync + Send + std::fmt::Debug + 'static
@ -43,3 +43,19 @@ impl OutgoingWebhookType for webhooks::OutgoingWebhook {
header.push((headers::X_WEBHOOK_SIGNATURE.to_string(), signature.into()))
}
}
#[derive(Debug, Clone, Copy)]
pub(crate) enum WebhookDeliveryAttempt {
InitialAttempt,
AutomaticRetry,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub(crate) struct OutgoingWebhookTrackingData {
pub(crate) merchant_id: String,
pub(crate) business_profile_id: String,
pub(crate) event_type: enums::EventType,
pub(crate) event_class: enums::EventClass,
pub(crate) primary_object_id: String,
pub(crate) primary_object_type: enums::EventObjectType,
}