Skip to content

Add a direct backend for plain blocking code - #277

Merged
ghostdogpr merged 2 commits into
mainfrom
direct-backend
Oct 25, 2026
Merged

ghostdogpr merged 2 commits into
mainfrom
direct-backend

Conversation

@ghostdogpr

@ghostdogpr ghostdogpr commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Adds sage-client-direct, a client for plain blocking code with no effect library dependency. Each command blocks the calling thread and returns its result, failures are thrown, and interrupting the thread cancels the wait. It is meant for virtual threads, for example in frameworks such as Eezo that serve each request on one.

SageClient.use(SageConfig.fromUri(sys.env("REDIS_URL"))) { client =>
  client.set("greeting", "hello")
  val greeting = client.get[String]("greeting") // Some("hello")
}
  • sage-compat-direct binds kyo.compat with plain JDK code and passes the conformance suite. Long flatMap chains continue on a fresh virtual thread to stay stack-safe, and lock bodies always run on the caller's thread so they keep its thread-local context.
  • Streaming helpers return Iterator. Subscriptions return a closeable blocking iterator, and onMessage, onPatternMessage, and onShardMessage deliver messages to a callback on a background virtual thread.
  • Adds the direct cells to CI, the examples, the benchmarks, and the docs.

Add `sage-client-direct`, a client for plain blocking code on virtual threads with no effect library dependency. Each command blocks the
calling thread and returns its result, failures are thrown, and interrupting the thread cancels the wait.

- `sage-compat-direct` binds `kyo.compat` with plain JDK code. Long flatMap chains continue on a fresh virtual thread, and lock bodies
  always run on the caller's thread so they keep its thread-local context.
- Streaming helpers return `Iterator`, subscriptions return a closeable blocking iterator, and `onMessage`, `onPatternMessage`, and
  `onShardMessage` deliver messages to a callback on a background virtual thread.
- Add the direct cells to CI, the examples, the benchmarks, and the docs, plus two tests for interrupted closes in the shared runtime.
@ghostdogpr
ghostdogpr merged commit bb86410 into main Oct 25, 2026
11 checks passed
@ghostdogpr
ghostdogpr deleted the direct-backend branch October 25, 2026 09:01
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.

1 participant