Native AOT
For ahead-of-time compiled deployments with minimal startup time and memory footprint, use
BuildAot with the source-generated registration:
using Restate.Sdk.Hosting;
await RestateHost.CreateBuilder()
.AddService<GreeterService>()
.BuildAot() // Slim Kestrel host, no reflection
.RunAsync();
Publish as a self-contained NativeAOT binary:
dotnet publish -c Release -r linux-x64
The source generator emits AddRestateGenerated() which registers all service definitions
and JSON serializer contexts without reflection. See the
NativeAotGreeter
sample for a complete working example.
Tip: Set
<PublishAot>true</PublishAot>in your.csprojto enable AOT compilation. The SDK's source generator handles all trimming and serialization concerns automatically.