Skip to content

restatedev/sdk-ruby

Repository files navigation

Documentation Examples Discord Twitter

Restate Ruby SDK

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(ctx, name)
    ctx.run_sync('build-greeting') { "Hello, #{name}!" }
  end
end

Community

Using the SDK

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 install

Or add the gem to an existing project:

gem install restate-sdk

Typed handlers with T::Struct

Use Sorbet's T::Struct for typed input/output with automatic JSON Schema generation:

require 'restate'

class RegistrationRequest < T::Struct
  const :event_name, String
  const :attendee, String
  const :num_guests, Integer
  const :note, T.nilable(String)
end

class RegistrationResponse < T::Struct
  const :registration_id, String
  const :status, String
end

class EventService < Restate::Service
  handler :register, input: RegistrationRequest, output: RegistrationResponse
  def register(ctx, request)
    registration_id = ctx.run_sync('create-registration') do
      "reg_#{request.event_name}_#{rand(10_000)}"
    end

    RegistrationResponse.new(
      registration_id: registration_id,
      status: 'confirmed'
    )
  end
end

See more in the User Guide and the examples/ directory.

Contributing

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!

Local development

  • Ruby >= 3.1
  • Rust toolchain
  • Docker (for integration tests)
  • Java 21+ (for sdk-test-suite integration tests)

Install dependencies and build:

bundle install
make build

Run the full verification suite (build, lint, typecheck, tests):

make verify

Run integration tests (requires Docker + Java 21+):

make test-integration

Releasing the package

  1. Pull latest main:

    git checkout main && git pull
  2. 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"
  3. Update the lock file and verify:

    make build
  4. 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors