RedCrab Request–reply over brokers for Event-Driven systems: Checkable Responsibility Allocation to Boundary elements
Call a service across an event broker as if it were a local method.
RedCrab wraps request–reply on Kafka, Redpanda and Apache Pulsar. A node awaits a typed method; RedCrab turns the call into a request event, matches the reply event that comes back, and returns the result or a typed failure. Streams, correlation ids and wire formats stay inside the boundary, and the services stay decoupled.
How RedCrab is adopted, step by step
$ dotnet add package RedCrab --version 1.0.2
kafka://pulsar://
Kafka, Redpanda, Apache Pulsar
A method call on the outside, events on the inside
The nodes never call each other. Each one only produces and consumes events, so either side can stop, restart or scale out without the other knowing; RedCrab gives the code the shape of a call.
- The requestor awaits a generated method. RedCrab registers the pending call under a fresh correlation id and publishes a request event on the operation's request stream.
- A replier receives it. The repliers of the operation share the stream as one group, so each request is served once, by one of them; RedCrab calls the handler you wrote with typed arguments.
- The reply is an event too. The result, or a failure the contract declares, goes back on the reply stream with the same correlation id.
- The call returns. RedCrab matches the reply to the waiting call and returns the typed result or throws the typed failure. A deadline or a cancelled token ends the call; a reply that comes later goes to the node's local policy.
Operations are .NET types
A node calls a generated facade and implements a generated projection. It never sees a stream, a correlation id or a wire format; the scheme of the endpoint chooses the broker.
services.AddRedCrab()
.AddCluster("carservices", "kafka://localhost:9092")
.WithRequestTimeout(15000)
.Register();
services.AddRedCrabKafka(); // or AddRedCrabPulsar()
services.AddRedCrabSdk(); // the generated facades
await provider.InitializeRedCrabAsync();
// reads the contract from the broker and checks its hash
// the requesting side
var car = await carservices.GetCarDetails(carId);
// the serving side
sealed class GetCarDetailsReplier
: CarservicesReplier.IGetCarDetails {
public Task<CarDetailsReply> ReplyAsync(int carId)
=> …;
}
What a node can do
19 use cases, in five groups, each with the proof that shows it today: a scenario of the live test on a real broker, or a test.
All 19 use cases, with their proofs and the code of the samples →
Every part of a remote call has one place
The reference paper places the work a broker brings into a call, and RedCrab holds each piece where it is placed.
- Two questions place every responsibility: is it settled by one node or agreed among several, and would it still exist if the call were local?
- Four families follow from the answers, and the 15 responsibilities of one exchange each fall in one of them.
- Three objectives give each family one treatment, and a test of RedCrab pins every responsibility where its treatment puts it.
From one package to a running node
Install the host and a transport from nuget.org, publish a contract, generate the node's code, and call.