Skip to main content

HttpEgress

Trait HttpEgress 

Source
pub trait HttpEgress: Send + Sync {
    // Required methods
    fn get(
        &self,
        url: &str,
        timeout: Duration,
        max_bytes: usize,
        traceparent: Option<&str>,
    ) -> Result<HttpResponse, FnError>;
    fn post(
        &self,
        url: &str,
        body: &[u8],
        timeout: Duration,
        max_bytes: usize,
        traceparent: Option<&str>,
    ) -> Result<HttpResponse, FnError>;
}
Expand description

A blocking HTTP egress service backing the uni.http.* host functions.

Methods are synchronous because the Rhai engine runs scripts synchronously (inside DataFusion scalar/procedure execution). Implementations must be safe to call from within a Tokio runtime context — e.g. by running the request on a dedicated OS thread rather than blocking a Tokio worker. URL allow-listing, timeout, and response-size limits are enforced by the caller against the plugin’s granted crate::Capability::Network; the timeout and max_bytes arguments carry those decisions into the request.

traceparent, when Some, is injected as the W3C traceparent request header so the host’s trace context propagates across the plugin boundary into the outbound call (see crate::observability::TraceContext::to_traceparent).

Required Methods§

Source

fn get( &self, url: &str, timeout: Duration, max_bytes: usize, traceparent: Option<&str>, ) -> Result<HttpResponse, FnError>

Perform a blocking HTTP GET, reading at most max_bytes of the body.

§Errors

Returns FnError on connection, timeout, or transport failure.

Source

fn post( &self, url: &str, body: &[u8], timeout: Duration, max_bytes: usize, traceparent: Option<&str>, ) -> Result<HttpResponse, FnError>

Perform a blocking HTTP POST of body, reading at most max_bytes of the response body.

§Errors

Returns FnError on connection, timeout, or transport failure.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§