This repository is a working, local-first reference microservice for Go developers who are new to Restate. It models a checkout flow with durable orchestration, keyed state, compensation, event ingestion, service discovery, versioned contracts, and layered tests. AWS Lambda packaging is included, but an AWS account is not required for development.
| Component | Restate type | Responsibility |
|---|---|---|
OrderWorkflow |
Workflow | Runs checkout exactly once per order ID |
Inventory |
Virtual Object | Serializes stock changes per SKU |
Payment |
Virtual Object | Makes charge/refund idempotent per order |
OrderEvents |
Virtual Object | Consumes ordered Kafka events per order key |
Notification |
Basic Service | Demonstrates a replay-safe external side effect |
Redpanda supplies a single-node, Kafka-compatible local broker. Restate consumes
orders.submitted.v1 directly and invokes OrderEvents/OnOrderSubmitted; there
is no handwritten consumer loop or offset management. See the
architecture guide for the full request and event paths.
- Go 1.25 or newer
- Docker Desktop or another Docker-compatible runtime
curl- Optional for AWS only: AWS CLI and AWS SAM CLI
The Restate CLI is useful for exploration but is not required: the repository's
local-setup command uses the Restate Admin API directly.
Start Restate and Redpanda:
make infra-upStart the Go endpoint in a second terminal:
make runDiscover the Go services, create the Kafka topic, and install the event subscription from a third terminal:
make setup-localThe setup is idempotent and safe to repeat during local development.
curl localhost:8080/Inventory/coffee-beans/Seed \
--json '{"quantity":10}'
curl localhost:8080/OrderWorkflow/order-http-1001/Run \
--json '{
"customerId":"customer-42",
"sku":"coffee-beans",
"quantity":2,
"amountCents":2400
}'The example event uses order-1001 as both its Kafka key and event subject:
make publish-eventKafka delivery is asynchronous. Inspect its durable receipt and workflow:
curl localhost:8080/OrderEvents/order-1001/Get
curl localhost:8080/OrderWorkflow/order-1001/StatusOpen http://localhost:9070 to inspect discovered
services, journals, invocations, state, retries, and the Kafka subscription.
Stop the infrastructure with make infra-down.
make test # formatting, vet, unit, and contract tests
make test-contract # strict order-submitted contract tests only
make test-integration # starts local infrastructure and tests HTTP + Kafka pathsThe integration suite requires Docker but no cloud credentials. It builds the service into a temporary directory, registers it, creates the subscription, uses unique order/SKU keys, and verifies state through Restate ingress. See the testing strategy.
cmd/
local/ Local endpoint containing every service
local-setup/ Idempotent discovery and subscription bootstrap
event-publisher/ Standard-library Redpanda/Kafka REST producer
*-lambda/ AWS Lambda entrypoints
config/ Local Restate Kafka configuration
contracts/ Versioned JSON Schema and example events
exercises/ Gamified developer onboarding track
internal/
contracts/ Strict boundary validation
domain/ Requests, events, responses, and status types
eventing/ Replaceable local publisher adapter
inventory/ Stateful stock virtual object
order/ Durable checkout workflow and notification service
orderevents/ Kafka-triggered order virtual object
payment/ Idempotent payment virtual object
restateadmin/ Small Admin API client for local discovery
test/integration/ Full-stack HTTP and Kafka tests
docs/ Architecture, discovery, testing, and AWS guides
Start at exercises/README.md. The course assumes strong Go skills and teaches Restate by asking developers to collect points and badges for observable behaviors: per-key serialization, durable replay, idempotency, contract enforcement, event delivery, compensation, and discovery.
The same service implementations are bound to independent Lambda entrypoints. Restate invokes versioned Lambda functions directly; API Gateway is not required between Restate and a service handler. See docs/aws-deployment.md. The local Redpanda broker can later be replaced by Amazon MSK or Confluent Cloud; the event contract and Restate handler remain unchanged.