Skip to main content

Crate restate_email

Crate restate_email 

Source
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 by email-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

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-email workers.

Structs§

CorrelationId
Correlation identifier carried end-to-end from queue to transport.
IdempotencyKey
Provider idempotency token for safe retries.
RestateSendOptions
Restate-specific options for a single send attempt.
SendOptions
Per-send controls shared by structured and raw transport sends.
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.
Service
Concrete Restate service implementation over a transport resolver.
ServiceClient
Client to invoke the Service service from another handler.
TransportKey
Configured transport key (e.g. "primary", "fallback").
TransportOptionRegistry
Registry of queue/wire codecs for concrete TransportOption types.
TransportOptions
Per-send transport options.
TransportOptionsSeed
DeserializeSeed for TransportOptions.

Enums§

InvocationMode
How far a Restate-backed send is followed before it returns.
StringNewtypeError
Reasons a string value cannot be promoted into a validated string newtype defined via the crate::string_newtype! macro.
TransportOptionRegistryError
Failure to register a provider-option codec.

Constants§

STRING_NEWTYPE_MAX_BYTES
Maximum byte length of a string-newtype value.

Traits§

RuntimeBound
Re-export of email_transport::RuntimeBound.
TransportOption
Marker for typed provider-specific send options.