Skip to main content

PushSender

Trait PushSender 

Source
pub trait PushSender:
    Send
    + Sync
    + 'static {
    // Required method
    fn send<'a>(
        &'a self,
        url: &'a str,
        event: &'a StreamResponse,
        config: &'a TaskPushNotificationConfig,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>;

    // Provided methods
    fn allows_private_urls(&self) -> bool { ... }
    fn allows_webhook_url(&self, _url: &str) -> bool { ... }
    fn requires_https(&self) -> bool { ... }
    fn max_delivery_duration(&self) -> Option<Duration> { ... }
}
Expand description

Trait for delivering push notifications to client webhooks.

Object-safe; used as Box<dyn PushSender>.

§A sender that connects to url guards it itself

The handler screens a URL when a config is created, by its form and without a DNS lookup. Everything at delivery time is the sender’s. One that POSTs to url should:

  • resolve it with resolve_public_addrs and connect to the addresses it returns, not to the name: a client that looks the name up again at connect, as most do, reopens DNS rebinding;
  • not follow redirects, since a 3xx to an internal address is the same attack by another route (a reqwest client follows up to ten by default);
  • send A2A-Delivery-Id (webhook::DELIVERY_ID_HEADER), the same on its own retries, so a receiver can tell them from a second event.

HttpPushSender does all three (audit SEC-17).

Required Methods§

Source

fn send<'a>( &'a self, url: &'a str, event: &'a StreamResponse, config: &'a TaskPushNotificationConfig, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>

Sends a streaming event to the client’s webhook URL.

§Errors

Returns an A2aError if delivery fails after all retries.

Provided Methods§

Source

fn allows_private_urls(&self) -> bool

Returns true if this sender allows webhook URLs targeting private/loopback addresses. Used by the handler to skip SSRF validation at push config creation time in testing environments.

Default: false (SSRF protection enabled).

Source

fn allows_webhook_url(&self, _url: &str) -> bool

Whether this sender will deliver to url at all, checked when a push config is created so a URL the sender would refuse is rejected then, not stored. Default: true. HttpPushSender answers from its with_allowed_hosts allowlist.

Source

fn requires_https(&self) -> bool

Whether this sender delivers only to https:// webhooks, checked when a push config is created so an http:// URL is refused then, with a reason. Default: false. HttpPushSender answers from https_only.

Source

fn max_delivery_duration(&self) -> Option<Duration>

The longest a single send can take, if this sender can say — its whole retry schedule, not one attempt.

§Why this exists

Background delivery bounds every send with HandlerLimits::push_delivery_timeout, and a sender whose own schedule is longer than that bound never finishes it. At the shipped defaults HttpPushSender schedules three attempts at 10s each with [1s, 2s] backoff, after a 5s DNS bound — 38s — against a 30-second bound: every attempt starts, the first two always finish, and the third has what is left, 2s when every request runs to its timeout. Until 2026-10-12 it was 98s against 5s, and one attempt of three ran.

Reporting a duration here lets the server tell “your webhook is slow” apart from “your two timeouts disagree” — see push_outcome::TIMEOUT_TRUNCATED.

Default: None, meaning “I cannot say”. A None sender is never reported as truncated, because nothing is known to have been cut short.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§