A library for managing and validating grain call transitions in Microsoft Orleans applications. It allows you to define allowed communication patterns between grains and enforce them at runtime.
- Define allowed grain-to-grain communication patterns
- Validate grain call transitions at runtime
- Detect and prevent circular dependencies
- Support for method-level granularity
- Reentrancy control
- Client-to-grain call validation
dotnet add package ManagedCode.Orleans.Graph
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.Method(a => a.MethodA1(), b => b.MethodB1())
.And()
.AllowClientCallGrain<GrainA>();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.AllMethods()
.And()
.AllowClientCallGrain<GrainA>();
});
Here are more examples of how to configure the graph in your Orleans application:
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.AllMethods();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.Method(a => a.MethodA1(), b => b.MethodB1());
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.WithReentrancy()
.AllMethods();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.AllMethods()
.And()
.AddGrainTransition<GrainB, GrainC>()
.AllMethods();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AllowClientCallGrain<GrainA>()
.And()
.AddGrainTransition<GrainA, GrainB>()
.AllMethods();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrainTransition<GrainA, GrainB>()
.AllMethods()
.And()
.AddGrainTransition<GrainB, GrainC>()
.AllMethods()
.And()
.AddGrainTransition<GrainC, GrainA>()
.AllMethods();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrain<IGrainA>()
.WithReentrancy();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrain<IGrainA>()
.AllMethods()
.WithReentrancy();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrain<IGrainA>()
.Method(a => a.MethodA1(GraphParam.Any<int>()))
.WithReentrancy();
});
builder.AddOrleansGraph()
.CreateGraph(graph =>
{
graph.AddGrain<IGrainA>()
.AllowClientCallGrain()
.WithReentrancy();
});
These examples demonstrate various ways to configure a grain to call itself, including method-level granularity, reentrancy, and client call validation.
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
If you have any questions or run into issues, please open an issue on the GitHub repository.
Created and maintained by ManagedCode