Skip to content

Commit 12c1a29

Browse files
committed
.
1 parent d923006 commit 12c1a29

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,28 @@ using (var tentaclePolling = new HalibutRuntime(services, Certificates.Alice))
5555
}
5656
```
5757

58-
Notice that while the configuration code changed, the request/response code didn't apart from the endpoint. Logically, the Octopus is still the request/response client, and the Tentacle is still the request/response server, even though the transport layer has Octopus as the TCP listener and Tentacle as the TCP client polling for work.
58+
Notice that while the configuration code changed, the request/response code didn't apart from the endpoint. Logically, the Octopus is still the request/response client, and the Tentacle is still the request/response server, even though the transport layer has Octopus as the TCP listener and Tentacle as the TCP client polling for work.
59+
60+
## RPC over Redis
61+
62+
Halibut supports executing RPC commands between nodes using a shared Redis queue as the communication mechanism. In this mode, nodes do not communicate directly with each other - all communication flows through Redis. This is particularly useful for scenarios where multiple nodes can all access a shared Redis instance but cannot establish direct network connections to each other.
63+
64+
### How it works
65+
66+
When using RPC over Redis:
67+
68+
- The client queues RPC requests in Redis
69+
- The server polls Redis for pending requests
70+
- The server processes requests and writes responses back to Redis
71+
- The client retrieves responses from Redis
72+
73+
This decoupled communication model allows nodes behind firewalls, in different networks, or with restricted connectivity to communicate as long as they can all reach the shared Redis instance.
74+
75+
### Usage
76+
77+
See the [SimpleLocalExecutionExample](source/Halibut.Tests/LocalExecutionModeFixture.cs) test for a complete example of how to set up and use RPC over Redis.
78+
79+
For more detailed information about the Redis queue implementation, refer to the [Redis Queue documentation](docs/RedisQueue.md).
5980

6081
## Failure modes
6182

source/Halibut/HalibutRuntime.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,22 @@ public async Task PollLocalAsync(Uri localEndpoint, CancellationToken cancellati
215215
{
216216
try
217217
{
218-
var request = await queue.DequeueAsync(cancellationToken).ConfigureAwait(false);
218+
var request = await queue.DequeueAsync(cancellationToken);
219219

220220
if (request != null)
221221
{
222222
ResponseMessage response;
223223
try
224224
{
225-
response = await invoker.InvokeAsync(request.RequestMessage).ConfigureAwait(false);
225+
response = await invoker.InvokeAsync(request.RequestMessage);
226226
}
227227
catch (Exception ex)
228228
{
229229
log.WriteException(EventType.Error, $"Error executing local request for {request.RequestMessage.ServiceName}.{request.RequestMessage.MethodName}", ex);
230230
response = ResponseMessage.FromException(request.RequestMessage, ex);
231231
}
232232

233-
await queue.ApplyResponse(response, request.RequestMessage.ActivityId).ConfigureAwait(false);
233+
await queue.ApplyResponse(response, request.RequestMessage.ActivityId);
234234
}
235235
}
236236
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
@@ -241,7 +241,7 @@ public async Task PollLocalAsync(Uri localEndpoint, CancellationToken cancellati
241241
catch (Exception ex)
242242
{
243243
log.WriteException(EventType.Error, $"Error in local polling loop for endpoint: {localEndpoint}", ex);
244-
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false);
244+
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
245245
}
246246
}
247247

0 commit comments

Comments
 (0)