Restate Go SDK 1.0
We’re pleased to announce the release of Restate Go SDK 1.0 🎉Migration guide
If you’re upgrading from 0.x, follow this migration guide, or point your coding agent at it: MIGRATION.md.Changes to the SDK modules
The SDK is now split into several independently versioned Go modules. In particular:- SDK remains
github.com/restatedev/sdk-go - Testing now needs to be pulled separately using
go get github.com/restatedev/sdk-go/[email protected], to avoid dependency pollution
internal and x submodules.We keep as experimental modules:- Mocks:
go get github.com/restatedev/sdk-go/x/[email protected] - Protoc plugin:
go get github.com/restatedev/sdk-go/x/[email protected]
Revamped error interfaces
We’ve overhauled the error interfaces used in the SDK APIs to be more explicit and to make them easier to use and evolve:TerminalErrorcompletes the invocation (or aRun) with a failure, with optional status code and metadata. You can build terminal errors usingrestate.ToTerminalErrororrestate.TerminalErrorf.RetryableErroris a non-terminal failure that gets retried (a status code). We will evolve this type in the future to support customizing the retry behavior.
BREAKING: BecauseContext operations such asTerminalErroris now a type, the oldTerminalError(...)constructor was renamed toToTerminalError:
Get, Run, Call and Wait now return a TerminalError directly instead of a generic error.
This makes the SDK’s error-handling model explicit right in the signatures: return a TerminalError for failures that are recorded in the Restate journal, and panic on any other error to let Restate retry.Randomness uses math/rand/v2
Rand(ctx) now returns a standard-library *math/rand/v2.Rand instead of a custom
interface, so the full stdlib API is available. It’s still seeded deterministically (same
sequence on every replay) and must not be used inside Run. UUIDs moved to their own
helper:Solidified options
We’ve cleaned up the option vocabulary across the SDK so it’s consistent and easier to evolve:- Retry policy options are now a single shared vocabulary: the same builders work for
Run/RunAsync/RunVoidand for the invocation retry policy (WithInvocationRetryPolicy), with consistent names and types. - Codecs are simplified: a single
encoding.Codecis used everywhere (handlers, services, ingress, value operations), set withWithCodec, and input/output codecs can now be configured independently viaWithInputCodec/WithOutputCodec.
(Preview) Scope and limit key to enable flow control
This release adds the SDK API for flow control, the new Restate 1.7 feature to cap how many invocations run concurrently within a scope, with optional hierarchical limit keys. Use it to bound cost (especially for AI agents, where every concurrent invocation is real model/API spend), shield downstream systems from bursts, and share capacity fairly across tenants.To use scope and limit keys in service to service communication:WithScope works on Service, Object and Workflow clients (and their …Send
variants); WithLimitKey works on both in-context calls and ingress requests/sends.NOTE: This API is in preview and is not enabled by default. To use it in restate-server 1.7, enable the flow control and protocol v7 experimental features viaRESTATE_EXPERIMENTAL_ENABLE_PROTOCOL_V7=trueandRESTATE_EXPERIMENTAL_ENABLE_VQUEUES=true(new clusters only). See https://docs.restate.dev/services/flow-control for details.
New Signals API
Signals are a first-class way for one invocation to communicate with another: an invocation waits on a named signal, and any other handler resolves or rejects it by referencing the target invocation’s ID.Noteworthy bumps
- Minimum Go version: 1.24 → 1.25.
testcontainers-goremoved from the core module. It now lives only in thetestingmodule (bumped tov0.43.0there), so consumers of the SDK no longer inherit Docker and its dependency tree.go.opentelemetry.io/otelv1.38.0 → v1.44.0google.golang.org/protobufv1.36.10 → v1.36.11github.com/invopop/jsonschemav0.13.0 → v0.14.0
What’s Changed
- Update shared core by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/137
- Bump sdk test suite by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/138
- Update shared core by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/140
- Refactor connection handling in ExecuteInvocation and IO helpers #132 by @neerajvipparla in https://github.com/restatedev/sdk-go/pull/143
- Update shared core, remove take output EOF case by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/145
- Move stream draining to request handler by @muhamadazmy in https://github.com/restatedev/sdk-go/pull/146
- Add/go license #134 by @neerajvipparla in https://github.com/restatedev/sdk-go/pull/144
- Fix license check CI step: match Go version to go.mod by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/147
- Scopes and signals by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/148
- Pre 1.0 changes by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/149
- Dep bumps by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/150
- Bump jsonschema dependency by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/151
- Bump testcontainers dependency by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/152
- Fix API change with testcontainers by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/153
- Remove exclusions we dont need by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/154
New Contributors
- @neerajvipparla made their first contribution in https://github.com/restatedev/sdk-go/pull/143
Check https://github.com/restatedev/sdk-go/releases/tag/v1.0.0 for more details.View on GitHub
What’s Changed
- Support non-deterministic codecs via PayloadOptions by @ciricc in https://github.com/restatedev/sdk-go/pull/122
- Improve Run docs by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/129
- Docs about otel client setup by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/130
- Add require_service_type flag to protoc-gen-go-restate by @jackkleeman in https://github.com/restatedev/sdk-go/pull/131
- Use WarpBuild runners for CI workflows by @tillrohrmann in https://github.com/restatedev/sdk-go/pull/136
New Contributors
- @ciricc made their first contribution in https://github.com/restatedev/sdk-go/pull/122
What’s Changed
Better integration with go’s Context
We have improved the interoperability with go’s Context, you can now wrap any context inside restate.Context using restate.WrapContext:restate.WithValue:Other changes
- Fix to opentelemetry library integration: now you don’t need to set the tracecontext propagator anymore. by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/124
- Change logging level to WARN for invocation failure. by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/127
What’s Changed
- Memory leak fix: Close wasm module when *Core is gc’d by @jackkleeman in https://github.com/restatedev/sdk-go/pull/125
New features:
- Added
restate.RunVoidas shortcut method to execute runs that return no value:
- Added test environment using testcontainers:
New Contributors
- @chronark made their first contribution in https://github.com/restatedev/sdk-go/pull/118
What’s Changed
- Use the correct logger by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/115
New features
protoc-restate-gonow generates ingress clients
- New API to concurrently wait Restate Futures:
WaitFirstto wait the first of the given futures to complete
Waitto create an iterator (usable infor range) to await futures as soon as they’re completed
WaitIter, likeWait, but with a “traditional iterator” API- All the new selector API now correctly support Restate cancellation feature.
Deprecations
restate.Rand(ctx).UUID()->restate.UUID(ctx)restate.Rand(ctx).Source()->restate.RandSource(ctx)- In subsequent releases,
restate.Rand(ctx)will returnmath/rand/v2Randobject instead of the internal interface. - Few changes to the Ingress API, including renaming the
Attach*API:AttachInvocation->InvocationByIdAttachService->ServiceInvocationByIdempotencyKeyAttachObject->ObjectInvocationByIdempotencyKeyAttachWorkflow->WorkflowHandle
SelectAPI is deprecated, replace it withWaitFirst,WaitorWaitIter
Breaking changes
- Ingress API
Sendreturn type changed, now it returnsSendResponse/SimpleSendResponseand splits result type to error type.- Return type of
Service/Object/Workflownow doesn’t implement anymoreSendRequester, but was replaced with an ad-hoc interface to carry on the generic information
Fixes
- Ingress API deserialized incorrectly send and attach responses, when used in combination with a Codec different from the default one.
Full changelog
- Generate Ingress client when using protoc-restate-go by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/109
- Few changes in the Rand API by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/106
- New concurrency API by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/108
- Protocol version 6 is supported by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/111
- Rename RandUUID to just UUID by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/112
- Changes to the Ingress API by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/110
- Test suite 3.2 upgrade by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/113
What’s Changed
- Also catch schema generation panic for non proto schem by @muhamadazmy in https://github.com/restatedev/sdk-go/pull/105
What’s Changed
- Catch schema generation panic by @muhamadazmy in https://github.com/restatedev/sdk-go/pull/104
Invocation retry policy
When used with Restate 1.5, you can now configure the invocation retry policy from the SDK directly. See https://github.com/restatedev/restate/releases/tag/v1.5.0 for more details on the new invocation retry policy configuration.More configuration
Allow to configure per-handler options in the reflection API throughConfigureHandler.What’s Changed
- Add retry policy options by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/92
- Clarify meaning of withMaxRetryAttempts by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/95
- Allow to configure per handler options when using the Reflect API by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/96
- Better workflow retention by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/97
- WithCodec should implement PromiseOption by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/99
- Grab seed from shared-core by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/101
What’s Changed
- Bumped Go minimum version to 1.24, Use native Go HTTP/2 server setup and graceful shutdown by @khatibomar in https://github.com/restatedev/sdk-go/pull/59
- Add health endpoint by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/84
- Fix read channel issue by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/86
- Dependency bumps by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/88
- Re-export options types by @jackkleeman in https://github.com/restatedev/sdk-go/pull/89
- Re-export Request struct so it can be mocked by @jackkleeman in https://github.com/restatedev/sdk-go/pull/90
- Fix ingress client
Invocation.IdandAttach/Outputfunctions by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/91
New Contributors
- @khatibomar made their first contribution in https://github.com/restatedev/sdk-go/pull/59
Fix goroutine leak in read path, see https://github.com/restatedev/sdk-go/pull/86 for more details.View on GitHub
- Added new options for services and handlers
WithAbortTimeout,WithEnableLazyState,WithIdempotencyRetention,WithInactivityTimeout,WithIngressPrivate,WithJournalRetentionandWithWorkflowRetention. Please note, these will work only from Restate 1.4 onward. Check the in-code documentation for more details. - Introduce new ingress client, thanks @strobus for the contribution!
- Several improvements to error messages
- Fix bug with protojson and schema generation
Changelog
- Improve error message when reflect skips methods by @jackkleeman in https://github.com/restatedev/sdk-go/pull/70
- Add discovery manifest v3 support by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/72
- Ensure input bytes are handled even if they come with an io.EOF by @jackkleeman in https://github.com/restatedev/sdk-go/pull/73
- More easy to identify Restate SDK started listening by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/75
- Improve error message around bad service/handlers by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/77
- Bump shared core by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/78
- Update shared core by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/81
- Fix protojsonschema ids issue by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/76
- Ingress sdk by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/82
- Bump shared core to 0.4.0 by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/83
What’s changed
https://github.com/restatedev/sdk-go/pull/73 - fix a bug related to HTTP1.1 serversView on GitHubWhat’s Changed
- Introduce
restate.RunAsyncto execute a side effect returning a future, allowing to combine it within arestate.Selectorby @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/68 - Improved JSON Schema support, and introduced schema derivation for
protojsonencoding by @jackkleeman in https://github.com/restatedev/sdk-go/pull/69
We’re pleased to announce the release of Golang SDK 0.16, in combination with Restate 1.3.
Check out the announcement blog post for more details about Restate 1.3 and the new SDK features: https://restate.dev/blog/announcing-restate-1.3/This SDK introduces the following new APIs:
- Support for
Runretry policies, throughRunOptions. For example by usingWithMaxRetryAttemptsyou can limit the amount of retry attempts before giving up. - Support the new features of Restate 1.3, including
GetInvocationId,AttachInvocationandCancelInvocationand metadata - The SDK now publishes auto-generated json schemas for the input/output handler types. This can be overriden using
JSONCodecWithCustomSchemaGenerator - Add ability to provide a name to
Sleep, for observability purposes, usingWithName
Full changelog
- Protocol V4 support by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/54
- SDK test suite 3.0 by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/55
- Fix KillTest by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/56
- Bump to protocol V5 by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/57
- Json schema & metadata by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/60
- Add GetInvocationId/AttachInvocation/CancelInvocation by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/61
- Add documentation field by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/62
- Add named sleep by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/63
- Add CLA automation by @tillrohrmann in https://github.com/restatedev/sdk-go/pull/65
- Fix error propagation of errors from VM when starting. by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/66
- Regenerate mocks by @jackkleeman in https://github.com/restatedev/sdk-go/pull/64
- Update shared core by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/67
New Contributors
- @tillrohrmann made their first contribution in https://github.com/restatedev/sdk-go/pull/65
What’s Changed
- Add comment about deterministic marshaling by @jackkleeman in https://github.com/restatedev/sdk-go/pull/52
- Experimental: Add mocking integration by @jackkleeman in https://github.com/restatedev/sdk-go/pull/53
What’s Changed
- WorkflowSend does not need a type parameter
- Use fully qualified proto service names by @jackkleeman in https://github.com/restatedev/sdk-go/pull/48
- Update to suite 2.3 by @jackkleeman in https://github.com/restatedev/sdk-go/pull/49
- Use test suite 2.4 by @jackkleeman in https://github.com/restatedev/sdk-go/pull/50
Fix go.mod to allow go install to workView on GitHub
What’s Changed
- Lambda support without httpadapter by @jackkleeman in https://github.com/restatedev/sdk-go/pull/47
- fix: usage of
a deprecated Node.js versionin CI by @hamirmahal in https://github.com/restatedev/sdk-go/pull/46
New Contributors
- @hamirmahal made their first contribution in https://github.com/restatedev/sdk-go/pull/46
What’s Changed
- Parse otel headers automatically + create otel example by @jackkleeman in https://github.com/restatedev/sdk-go/pull/39
- Use 1.6 test suite by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/41
- Implement workflows and durable promises by @jackkleeman in https://github.com/restatedev/sdk-go/pull/40
- Update test suite by @jackkleeman in https://github.com/restatedev/sdk-go/pull/44
This PR breaks essentially the entire API, as methods have been moved from
Context.Run et all to restate.Run(ctx) et all, which is much more pleasant.Serialisation issues will now always panic - this allows us to take error return values out of various api calls that don’t need them.The semantics of .Get() have changed - the zero value is now always returned if the key isn’t found. You can check explicitly for this case by providing a pointer type eg *string. Get will now only return errors in the case of cancellation, which will also only happen if eager state is disabled, which is not the default. As such, errors from gets are now very unlikely and you can just return them without another thought.It is also notable that you can now provide many more method signatures to .Reflect().What’s Changed
- Ensure servicemethod is logged by @jackkleeman in https://github.com/restatedev/sdk-go/pull/28
- Use panics for serialisation errors by @jackkleeman in https://github.com/restatedev/sdk-go/pull/32
- Add TerminalErrorf by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/30
- Move headers and delays into requestoption/ send option by @jackkleeman in https://github.com/restatedev/sdk-go/pull/34
- Always interact with ctx through facilitator functions by @jackkleeman in https://github.com/restatedev/sdk-go/pull/35
- Allow more method signatures in .Reflect() by @jackkleeman in https://github.com/restatedev/sdk-go/pull/33
- Remove err key not found by @jackkleeman in https://github.com/restatedev/sdk-go/pull/36
There are several breaking changes in this release:
- NewServiceRouter et al -> NewService
- restate.Service and restate.Object -> restate.Reflect
- Sleep now returns an error, which is returned in the case of invocation cancellation
What’s Changed
- Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 by @dependabot in https://github.com/restatedev/sdk-go/pull/15
- Bump golang.org/x/net from 0.21.0 to 0.23.0 by @dependabot in https://github.com/restatedev/sdk-go/pull/16
- Enable go sdk to use the new restate-sdk-test-tool by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/19
- Prepare integration.yaml for embedding in runtime repo by @slinkydeveloper in https://github.com/restatedev/sdk-go/pull/22
- Add the rest of the test services by @jackkleeman in https://github.com/restatedev/sdk-go/pull/23
- Avoid ‘router’ terminology by @jackkleeman in https://github.com/restatedev/sdk-go/pull/25
- Support passing headers in calls by @jackkleeman in https://github.com/restatedev/sdk-go/pull/17
- Add protoc-gen-go-restate by @jackkleeman in https://github.com/restatedev/sdk-go/pull/18
- Add awakeable example by @jackkleeman in https://github.com/restatedev/sdk-go/pull/26
- Test various cancellation behaviour by @jackkleeman in https://github.com/restatedev/sdk-go/pull/24
- Unify restate.Service and restate.Object into restate.Reflect by @jackkleeman in https://github.com/restatedev/sdk-go/pull/27
New Contributors
- @dependabot made their first contribution in https://github.com/restatedev/sdk-go/pull/15
- @slinkydeveloper made their first contribution in https://github.com/restatedev/sdk-go/pull/19
What’s Changed
- Add doc comments everywhere by @jackkleeman in https://github.com/restatedev/sdk-go/pull/13
- Add a mechanism to obtain immutable request parameters by @jackkleeman in https://github.com/restatedev/sdk-go/pull/14
With v0.9.0, this repository is compatible with Restate v1, and is much closer to feature complete with other repos. Correctness has been validated using the Restate verification tests in restatedev/e2e. A 1.0 release will come when we have API stability, which will not come until we have some feedback from users.
What’s Changed
- Update for 1.0 and implement basic awakeables by @jackkleeman in https://github.com/restatedev/sdk-go/pull/2
- Async completions by @jackkleeman in https://github.com/restatedev/sdk-go/pull/3
- Use panics where possible, implement selector by @jackkleeman in https://github.com/restatedev/sdk-go/pull/4
- Bring handler registration closer in line to TS by @jackkleeman in https://github.com/restatedev/sdk-go/pull/5
- Move logs to slog by @jackkleeman in https://github.com/restatedev/sdk-go/pull/6
- Add rand implementation by @jackkleeman in https://github.com/restatedev/sdk-go/pull/7
- Add identity implementation by @jackkleeman in https://github.com/restatedev/sdk-go/pull/8
- Custom encoders by @jackkleeman in https://github.com/restatedev/sdk-go/pull/9
- Move to Go 1.21.x by @jackkleeman in https://github.com/restatedev/sdk-go/pull/10
- Implement shared context & various improvements by @jackkleeman in https://github.com/restatedev/sdk-go/pull/11
- Verif fixes, simplify void by @jackkleeman in https://github.com/restatedev/sdk-go/pull/12
New Contributors
- @jackkleeman made their first contribution in https://github.com/restatedev/sdk-go/pull/2