Skip to content

Move server code into Restate::Server module to avoid loading async eagerly#9

Merged
igalshilman merged 7 commits into
restatedev:mainfrom
yshaul:split-server-module
May 13, 2026
Merged

Move server code into Restate::Server module to avoid loading async eagerly#9
igalshilman merged 7 commits into
restatedev:mainfrom
yshaul:split-server-module

Conversation

@yshaul
Copy link
Copy Markdown
Contributor

@yshaul yshaul commented May 12, 2026

Summary

  • Move Restate::Server (Rack app) and Restate::ServerContext (execution context) into a Restate::Server module namespace under lib/restate/server/
  • require "restate" no longer loads the async gem, preventing conflicts with host apps like Rails
  • Server code loads lazily via Endpoint#app or explicitly via require "restate/server"

Class Renames

Before After
Restate::Server (class) Restate::Server::Handler
Restate::ServerContext Restate::Server::Context

Loading Options

  • require "restate" -- core only, no async (safe for Rails)
  • require "restate/server" -- core + server (loads async), for apps that need the server at boot
  • Endpoint#app -- lazy-loads server on demand (existing behavior, just deferred)

Test plan

  • All 44 existing specs pass
  • Verified require "restate" does NOT load Async
  • Verified require "restate/server" loads Async + Server::Handler + Server::Context
  • Verified Endpoint#app lazy-loads correctly (no async before, async after)

Made with Cursor

yshaul and others added 7 commits May 12, 2026 15:14
…agerly

`require "restate"` previously loaded server_context.rb which pulls in the
async gem unconditionally. This conflicts with host apps like Rails that
don't need the server runtime.

Move the Rack app and execution context into lib/restate/server/:
- Restate::Server (class) -> Restate::Server::Handler
- Restate::ServerContext -> Restate::Server::Context

The server module loads lazily via Endpoint#app or explicitly via
`require "restate/server"`. Core SDK loads remain async-free.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@igalshilman igalshilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@igalshilman igalshilman merged commit f28ae19 into restatedev:main May 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants