Skip to main content

Crate email_transport_restate

Crate email_transport_restate 

Source
Expand description

Restate ingress transport for outbound email delivery.

This crate implements email_transport::Transport on top of a Restate Email.send ingress invocation, so the same application code can hand a message to a durable queue instead of a provider. The wire contract it submits is owned by restate-email; the worker side of the contract lives there as well. Depending on this crate never pulls in the Restate SDK.

RestateTransport follows a send as far as its InvocationMode says: in the default InvocationMode::Queued mode it returns once Restate has durably accepted the invocation and reports the invocation id; in InvocationMode::Sent mode it waits for the worker and returns the worker’s provider report. A per-send RestateSendOptions overrides the configured mode and may delay a queued invocation.

§Quick start

use email_message::{Address, Body, Message};
use email_transport::{SendOptions, Transport};
use email_transport_restate::{RestateTransport, TransportKey};

let message = Message::builder(Body::text("Welcome"))
    .from_mailbox("sender@example.com".parse()?)
    .to(vec![Address::Mailbox("recipient@example.com".parse()?)])
    .build_outbound()?;

let transport = RestateTransport::new(
    TransportKey::new("transactional")?,
    "http://127.0.0.1:8080".parse()?,
);
transport.send(&message, &SendOptions::default()).await?;

§Authentication

Restate Cloud ingress requires an API key as a bearer token; configure it with RestateTransportBuilder::bearer_token. Self-hosted Restate has no built-in ingress authentication; a fronting reverse proxy that expects the same Authorization: Bearer header is covered by the same setter, and any other header scheme can be attached to a custom reqwest::Client passed to RestateTransportBuilder::client.

§Features

The default feature set enables the default reqwest client stack. Disable default features to choose reqwest’s transport/TLS features explicitly.

  • schemars: forwards JSON Schema derivation to the re-exported restate-email queue payload types.

§Example programs

Structs§

RestateSendOptions
Restate-specific options for a single send attempt.
RestateTransport
Email transport backed by a Restate Email.send ingress invocation.
RestateTransportBuilder
Builder for RestateTransport.
SendRequest
Queue payload consumed by Email.send.
SendRequestSeed
Registry-driven deserializer for SendRequest.
SendResponse
Wire-stable response shape returned by the Restate Email.send handler.
TransportKey
Configured transport key (e.g. "primary", "fallback").

Enums§

InvocationMode
How far a Restate-backed send is followed before it returns.