Restate is a system for easily building resilient applications using distributed durable async/await. This repository contains the Restate SDK for writing services in Golang.
- 🤗️ Join our online community for help, sharing feedback and talking to the community.
- 📖 Check out our documentation to get quickly started!
- 📣 Follow us on Twitter for staying up to date.
- 🙋 Create a GitHub issue for requesting a new feature or reporting a problem.
- 🏠 Visit our GitHub org for exploring other repositories.
- Go: >= 1.21.0
This repo contains an example based on the Ticket Reservation Service.
You can also check a list of examples available here: https://github.com/restatedev/examples?tab=readme-ov-file#go
Download and run restate, as described here v1.x
restate-serverIn another terminal run the example
cd restate-sdk-go/example
go run .In a third terminal register:
restate deployments register http://localhost:9080And do the following steps
- Add tickets to basket
curl -v localhost:8080/UserSession/azmy/AddTicket \
-H 'content-type: application/json' \
-d '"ticket-1"'
# true
curl -v localhost:8080/UserSession/azmy/AddTicket \
-H 'content-type: application/json' \
-d '"ticket-2"'
# trueTrying adding the same tickets again should return false since they are already reserved. If you didn't check out the tickets in 15min (if you are impatient change the delay in code to make it shorter)
- Check out
curl localhost:8080/UserSession/azmy/Checkout
# trueThis library follows Semantic Versioning.
The compatibility with Restate is described in the following table:
| Restate Server\sdk-go | 0.9 - 0.15 | 0.16 - 0.17 |
|---|---|---|
| 1.0 | ✅ | ❌ |
| 1.1 | ✅ | ❌ |
| 1.2 | ✅ | ❌ |
| 1.3 | ✅ | ✅ |
We’re excited if you join the Restate community and start contributing! Whether it is feature requests, bug reports, ideas & feedback or PRs, we appreciate any and all contributions. We know that your time is precious and, therefore, deeply value any effort to contribute!
To rebuild the internal core:
cd shared-core
cargo build --release
mv target/wasm32-unknown-unknown/release/shared_core_golang_wasm_binding.wasm ../internal/statemachineTo regenerate the protobuf contract between core and SDK:
buf generate --template internal.buf.gen.yamlThe mock package is mostly autogenerated but will require some very light editing. To generate run mockery in the root of this repo. Then check the git diff.
Certain structs (MockAfterFuture, MockAttachFuture, MockAwakeableFuture, MockDurablePromise, MockResponseFuture) and functions (NewMockClient, NewMockContext)
have been redefined in helpers.go and commented out in their respective files. Please continue this state of affairs if you regenerate mocks - not doing so will be a build
error.