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-exportedrestate-emailqueue payload types.
§Example programs
invoke_local_workerinvokesEmail.sendthrough Restate ingress with a raw HTTP client and waits for the response.direct_or_restatesends through the same application function using either a direct provider transport orRestateTransport.
Structs§
- Restate
Send Options - Restate-specific options for a single send attempt.
- Restate
Transport - Email transport backed by a Restate
Email.sendingress invocation. - Restate
Transport Builder - Builder for
RestateTransport. - Send
Request - Queue payload consumed by
Email.send. - Send
Request Seed - Registry-driven deserializer for
SendRequest. - Send
Response - Wire-stable response shape returned by the Restate
Email.sendhandler. - Transport
Key - Configured transport key (e.g.
"primary","fallback").
Enums§
- Invocation
Mode - How far a Restate-backed send is followed before it returns.