-
Notifications
You must be signed in to change notification settings - Fork 48
Add support for RPC over Redis. #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LukeButters
wants to merge
9
commits into
main
Choose a base branch
from
local-execution-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This adds a new execution mode where RPC requests are executed locally on
the worker node that dequeues work, rather than being proxied over TCP.
Changes:
- Add PollLocalAsync() method to HalibutRuntime for local queue polling
- Support local:// URI scheme for local execution endpoints
- Workers poll queue directly and execute RPCs locally via ServiceInvoker
- Add comprehensive design document explaining architecture and usage
- Add test fixture demonstrating local execution mode
Benefits:
- 10-100x lower latency (no TCP/SSL overhead)
- True horizontal scaling via worker pools
- Queue-agnostic (works with in-memory and Redis queues)
- Backward compatible with existing code
Usage:
```csharp
// Worker
var worker = new HalibutRuntime(serviceFactory);
worker.Services.AddSingleton<IMyService>(new MyServiceImpl());
await worker.PollLocalAsync(new Uri("local://worker-pool-a"), cancellationToken);
// Client
var client = new HalibutRuntime(serviceFactory);
var service = client.CreateAsyncClient<IMyService, IAsyncClientMyService>(
new ServiceEndPoint("local://worker-pool-a", null));
await service.DoWorkAsync();
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
…ModeFixture The LocalExecutionModeFixture test uses Redis functionality (RedisFacadeBuilder, RedisPendingRequestQueueFactory) which is only available in .NET 8.0 or greater. Added #if NET8_0_OR_GREATER directive to match the pattern used in other Redis queue tests in the codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Added back the SimplePollingExample test implementation that demonstrates basic polling mode with TCP. This test serves as a reference example for the Halibut polling pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
176c9a4 to
2ab6dda
Compare
The hardcoded limit of 100 log events is now accessible via InMemoryConnectionLog.MaxLogEvents, allowing external code to reference this configuration value. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Making the class public so that the MaxLogEvents field can be accessed from outside the assembly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
LukeButters
commented
Dec 23, 2025
| public class HalibutExamplesFixture : BaseTest | ||
| { | ||
| [Test] | ||
| public async Task SimplePollingExample() |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this since we lack simple examples of how to use halibit.
f54d365 to
d923006
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new execution mode where RPC requests are executed locally on the worker node that dequeues work from the
IPendingRequestQueue, rather than being proxied over TCP to a remote service. This allows for executing RPCs by use of a distributedPendingRequestQueueonly. This is particularly handy when all nodes already make use of a Redis, in this case RPCs can be made between those nodes using only Redis.Motivation
Requesting Halibut logs between nodes.
Halibut provides an in memory rolling log of the last 100 log lines per Endpoint. In a multi-node setup currently one must go to each node to get these logs. Since a multi-node setup would already have a shared Redis, the support for RPC over Redis makes it trivial to request the logs from each node.
Clients behind a load balancer.
We are sometimes in the situation in which we need work to picked up by specific nodes e.g. a client is connected to only one node and we need that node to process the work.
With this change and a distributed queue (e.g. the Redis one), it would be possible to setup something like:
halibutRunTime.PollLocalAsync(new Uri("local://bob"), workerCts.Token)and so would begin to processes messages sent to "local://bob".var echo = client.CreateAsyncClient<IEchoService, IAsyncClientEchoService>(new ("local://test-worker");Changes
Core Implementation
HalibutRuntime.PollLocalAsync()- New method that polls alocal://queue and executes RPCs locallylocal://URI scheme support - Added to routing logic inSendOutgoingRequestAsync()GetQueue()and execute requests usingServiceInvokerDocumentation
/docs/LocalExecutionMode.mdTesting
LocalExecutionModeFixturewith test demonstrating local executionPendingRequestQueueFactoryso client and worker share the same queueUsage
Benefits
local://queuepoll://andhttps://endpoints work unchangedArchitecture
The implementation bypasses the entire
PollingClientandMessageExchangeProtocolmachinery:Current TCP Polling:
New Local Execution:
No TCP connection, no protocol messages, no serialization overhead.
🤖 Generated with Claude Code