Expand description
Restate-backed worker contracts for outbound email delivery.
This crate exposes the serializable email worker contract and an optional
Restate service adapter. Provider-specific send options cross the queue
boundary through the registry-driven SendRequestSeed, using the
provider-keyed wire representation owned by email-transport.
The Restate service adapter is available as Service with the
service feature. The caller-side ingress transport lives in the
email-transport-restate
crate, which submits this contract through Restate ingress without
depending on restate-sdk.
§Quick start
use restate_email::{Service, StaticTransportRegistry};
use restate_sdk::{endpoint::Endpoint, service::IntoServiceDefinition};
let registry = StaticTransportRegistry::new();
let service = Service::new(registry).into_service_definition();
let _endpoint = Endpoint::builder().bind(service).build();§Securing the worker
Restate signs every request it makes to an SDK endpoint when the runtime is configured with a request identity key. Verify those signatures by registering the corresponding public keys on the endpoint builder; once at least one key is registered, unsigned requests are rejected. Registering several keys keeps both the old and the new key valid during rotation:
let _endpoint = Endpoint::builder()
.bind(service)
.identity_key("publickeyv1_w7YHemBctH5Ck2nQRQ47iBBqhNHy4FV7t2Usbye2A6f")?
.identity_key("publickeyv1_ChjENKeMvCtRnqG2mrBK1HmPKufgFUc98K8B3ononQvp")?
.build();Identity keys authenticate the Restate runtime to the worker; callers
authenticate to Restate ingress separately (see email-transport-restate).
§Features
The default feature set enables service for backwards-compatible worker
builds. Disable default features to consume only the SDK-free wire contract.
service: Restate worker service adapter and transport registry.transport-resend: registers Resend provider options and enables the Resend worker example.schemars: JSON Schema implementations and examples for queue contracts.rfc5322-string-compat: accepts the legacy RFC 5322 string address shape supported byemail-message.
§Platform support
This crate targets native Restate workers. Transport implementations may
support additional platforms, but Service depends on Restate’s
native endpoint/runtime integration.
§Examples
restate_email_workerbuilds a worker with a custom transport and optional identity-key verification.restate_resend_workerwiresemail_kit::transport::resend::ResendTransportinto the service; it requires thetransport-resendfeature.
Re-exports§
pub use transport::CatchAllTransportResolver;pub use transport::StaticTransportRegistry;pub use transport::TransportLookupError;pub use transport::TransportResolver;
Modules§
- transport
- Transport resolution helpers for
restate-emailworkers.
Structs§
- Correlation
Id - Correlation identifier carried end-to-end from queue to transport.
- Idempotency
Key - Provider idempotency token for safe retries.
- Restate
Send Options - Restate-specific options for a single send attempt.
- Send
Options - Per-send controls shared by structured and raw transport sends.
- 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. - Service
- Concrete Restate service implementation over a transport resolver.
- Service
Client - Client to invoke the
Serviceservice from another handler. - Transport
Key - Configured transport key (e.g.
"primary","fallback"). - Transport
Option Registry - Registry of queue/wire codecs for concrete
TransportOptiontypes. - Transport
Options - Per-send transport options.
- Transport
Options Seed DeserializeSeedforTransportOptions.
Enums§
- Invocation
Mode - How far a Restate-backed send is followed before it returns.
- String
Newtype Error - Reasons a string value cannot be promoted into a validated string newtype
defined via the
crate::string_newtype!macro. - Transport
Option Registry Error - Failure to register a provider-option codec.
Constants§
- STRING_
NEWTYPE_ MAX_ BYTES - Maximum byte length of a string-newtype value.
Traits§
- Runtime
Bound - Re-export of
email_transport::RuntimeBound. - Transport
Option - Marker for typed provider-specific send options.