pub struct HttpPushNotificationSender { /* private fields */ }Expand description
HTTP-based push notification sender with retry and SSRF validation.
POSTs JSON payloads to webhook URLs. Retries up to 3 times with exponential backoff
(1s, 2s, 4s) on failure. Validates webhook URLs with validate_webhook_url before
every delivery (SSRF prevention), and new’s client checks every address a
webhook’s host resolves to when it connects, so a name pointed at an internal address is
refused too.
Implementations§
Source§impl HttpPushNotificationSender
impl HttpPushNotificationSender
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new sender whose client reaches public addresses only — the URL’s and every address its host resolves to — follows no redirect, ignores proxy settings, gives up on an attempt after 10 seconds and on a connection after 5 seconds. When that client cannot be built, every delivery fails; no unguarded client is used in its place.
Sourcepub fn with_client(client: Client) -> Self
pub fn with_client(client: Client) -> Self
Creates a new sender with a custom reqwest::Client.
The client should disable redirects (reqwest::redirect::Policy::none())
and set a timeout: URL validation covers the registered URL only, so a
followed redirect, or a host name resolving to an internal address, can reach an
address the validation would have refused. new’s client checks both.
Trait Implementations§
Source§impl Default for HttpPushNotificationSender
impl Default for HttpPushNotificationSender
Source§impl PushNotificationSender for HttpPushNotificationSender
impl PushNotificationSender for HttpPushNotificationSender
Source§fn send_status_update<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
event: &'life2 TaskStatusUpdateEvent,
config: &'life3 TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn send_status_update<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
event: &'life2 TaskStatusUpdateEvent,
config: &'life3 TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn send_artifact_update<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
event: &'life2 TaskArtifactUpdateEvent,
config: &'life3 TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn send_artifact_update<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
url: &'life1 str,
event: &'life2 TaskArtifactUpdateEvent,
config: &'life3 TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn send_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
update: &'life1 StreamResponse,
config: &'life2 TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
update: &'life1 StreamResponse,
config: &'life2 TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
config, as the StreamResponse a streaming
client receives ({"statusUpdate": …} or {"artifactUpdate": …}). Read moreAuto Trait Implementations§
impl !RefUnwindSafe for HttpPushNotificationSender
impl !UnwindSafe for HttpPushNotificationSender
impl Forget for HttpPushNotificationSender
impl Freeze for HttpPushNotificationSenderwhere
*const ArcInner<ClientRef> is !null: Freeze,
PhantomData<ArcInner<ClientRef>>: Freeze,
*const ArcInner<EgressPolicy> is !null: Freeze,
PhantomData<ArcInner<EgressPolicy>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl Move for HttpPushNotificationSender
impl Send for HttpPushNotificationSender
impl Sync for HttpPushNotificationSender
impl Unpin for HttpPushNotificationSender
impl UnsafeUnpin for HttpPushNotificationSenderwhere
*const ArcInner<ClientRef> is !null: UnsafeUnpin,
PhantomData<ArcInner<ClientRef>>: UnsafeUnpin,
*const ArcInner<EgressPolicy> is !null: UnsafeUnpin,
PhantomData<ArcInner<EgressPolicy>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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