Note: This SDK is currently under active development. APIs may change between releases.
Restate is a system for easily building resilient applications using distributed durable async/await. This repository contains the Restate SDK for writing services in Ruby.
require 'restate'
class Greeter < Restate::Service
handler def greet(name)
Restate.run_sync('build-greeting') { "Hello, #{name}!" }
end
end
class Counter < Restate::VirtualObject
state :count, default: 0
handler def add(addend)
self.count += addend
end
shared def get
count
end
end- 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.
Prerequisites:
- Ruby >= 3.1
For brand-new projects, we recommend using the Restate Ruby Template:
cp -r template/ my-restate-service
cd my-restate-service
bundle installOr add the gem to an existing project:
gem install restate-sdkUse dry-struct for typed input/output with automatic JSON Schema generation:
require 'restate'
require 'dry-struct'
module Types
include Dry.Types()
end
class RegistrationRequest < Dry::Struct
attribute :event_name, Types::String
attribute :attendee, Types::String
attribute :num_guests, Types::Integer
attribute? :note, Types::String # optional attribute
end
class RegistrationResponse < Dry::Struct
attribute :registration_id, Types::String
attribute :status, Types::String
end
class EventService < Restate::Service
handler :register, input: RegistrationRequest, output: RegistrationResponse
def register(request)
registration_id = Restate.run_sync('create-registration') do
"reg_#{request.event_name}_#{rand(10_000)}"
end
RegistrationResponse.new(
registration_id: registration_id,
status: 'confirmed'
)
end
endSee more in the User Guide and the examples/ directory.
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!
- Ruby >= 3.1
- Rust toolchain
- Docker (for integration tests)
- Java 21+ (for sdk-test-suite integration tests)
Install dependencies and build:
bundle install
make buildRun the full verification suite (build, lint, typecheck, tests):
make verifyRun integration tests (requires Docker + Java 21+):
make test-integration-
Pull latest main:
git checkout main && git pull -
Bump the version in both files:
lib/restate/version.rb— e.g.VERSION = '0.5.0'ext/restate_internal/Cargo.toml— e.g.version = "0.5.0"
-
Update the lock file and verify:
make build
-
Commit, tag, and push:
git add -A git commit -m "Release v0.5.0" git tag -m "Release v0.5.0" v0.5.0 git push origin main v0.5.0
The release workflow will build pre-compiled native gems for all platforms (x86_64/aarch64 Linux, macOS, musl) and publish them to RubyGems.