Distribution 2.1.9
See the version list below for details.
dotnet add package Distribution --version 2.1.9
NuGet\Install-Package Distribution -Version 2.1.9
<PackageReference Include="Distribution" Version="2.1.9" />
paket add Distribution --version 2.1.9
#r "nuget: Distribution, 2.1.9"
// Install Distribution as a Cake Addin #addin nuget:?package=Distribution&version=2.1.9 // Install Distribution as a Cake Tool #tool nuget:?package=Distribution&version=2.1.9
Distribution - Virtual Actor Framework
There is decent amount of actor-like frameworks, including those that support an idea of Virtual Actors, e.g. Orleans
and Proto.Actor
The two mentioned frameworks are the most flexible but have some drawbacks, like extra build step or inability to use different transport protocol. Below is the list of features built in the current framework. Each of them can be considered as an advantage or a disadvantage depending on specific use-case.
Status
For virtual actors and reactive store
Install-Package Distribution
For clusters and interserver communication
Install-Package Distribution.Cluster
Features
- Safe single-threaded execution in a background worker without locks
- Zero configuration
- Local actors and store are cross-platform .NET Standard 2.0
- UDP broadcasting for automatic service discovery without a single point of failure
- Peer-To-Peer network of independent nodes without consensus leaders
- Random placement of virtual actors within a cluster
- Ability to create multiple instances of the same type of actor using unique ID
- Ability to override any layer, including protocol, actor placement strategy, service discovery, etc
- No dangerous binary serialization or 3rd party serialization libraries
- Simple C# POCO structs for messages, no attributes or other decorators
- Process messages using single or multiple actors with
[Subscription]
attribute - Kestrel server middleware to process message queries
- Automatic loading and mapping for actors and messages at startup
Sample
This is an example of using actors locally within the same app.
// Define message and response format
public class DemoMessage { public string Name { get; set; }}
public class DemoResponse { public string Data { get; set; }}
// Define actor processing this particular message
public class DemoActor
{
[Processor]
public virtual Task<DemoResponse> SomeAction(DemoMessage message)
{
return Task.FromResult(new DemoResponse { Data = "Response from actor" });
}
}
// Processing
public class Client
{
async Task SendMessageToActor()
{
var scene = new Scene();
var message = new DemoMessage { Name = "Message to actor" };
var response = await scene.Send<DemoResponse>("Custom Actor ID", message);
Console.WriteLine("Response : " + response.Data);
}
}
An example with a distributed network of actors in the cluster is a bit more complex and can be found in the Samples directory.
Also, can be used as an alternative to RX.NET.
Disclaimer
In order to keep things simple and flexible, the main focus was on simplicity and scalability rather than performance.
Notes
Practically all parts of this framework use the most basic implementation of each layer meaning that it's a general purpose implementation that may need to be extended to solve more specific problems.
- HTTP and JSON are somewhat slow, but were chosen for communication instead of sockets to make it easier to build a network of a million of nodes without a need to manage permanent connections between peers.
- UDP broadcasting can detect nodes within the same network segment. To make peer discovery global there will be a need for services like Consul or manual NAT traversing.
- There is a heavy use of reflection for mapping between actors and messages. No benchmarks, but switching to compiled delegates may improve latency.
Improvements
Even though existing modules are the most basic at the core, they can be easily extended or overridden to achieve more specific goals.
- When there is no requirement to have millions of nodes, it's possible to implement
ICommunicator
and use sockets with Message Pack or Flat Buffers for lower latency. - Peer discovery is encapsulated inside of the
Beacon
class. When needed, it's easy to override any of its method or implementIBeacon
to use it withConsul
or some other service discovery tool.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Interactive (>= 6.0.1)
- System.Threading.Channels (>= 8.0.0)
- System.Threading.Tasks (>= 4.3.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Distribution:
Package | Downloads |
---|---|
Canvas.Core
Internal package used in Canvas.Views.Web |
|
Distribution.Stream
HTTP service with streaming and parallel execution. |
|
Distribution.Service
HTTP service with streaming and parallel execution. |
|
Distribution.Cluster
General purpose virtual actor framework for peer-to-peer microservices or in-process communication within the same app with possible extension to blockchains. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.1 | 117 | 10/25/2024 |
2.2.0 | 48 | 10/25/2024 |
2.1.9 | 50 | 10/25/2024 |
2.1.8 | 95 | 9/10/2024 |
2.1.7 | 362 | 8/24/2024 |
2.1.6 | 389 | 6/2/2024 |
2.1.5 | 113 | 5/26/2024 |
2.1.2 | 141 | 5/22/2024 |
2.1.1 | 153 | 5/19/2024 |
2.1.0 | 65 | 5/19/2024 |
2.0.9 | 62 | 5/17/2024 |
2.0.8 | 62 | 5/16/2024 |
2.0.7 | 60 | 5/16/2024 |
2.0.6 | 57 | 5/15/2024 |
2.0.5 | 322 | 3/25/2024 |
2.0.4 | 247 | 3/18/2024 |
2.0.3 | 84 | 3/18/2024 |
2.0.2 | 83 | 3/18/2024 |
2.0.1 | 183 | 3/15/2024 |
2.0.0 | 79 | 3/15/2024 |
1.3.5 | 116 | 3/14/2024 |
1.3.3 | 79 | 3/14/2024 |
1.3.2 | 86 | 3/14/2024 |
1.3.1 | 115 | 3/14/2024 |
1.3.0 | 110 | 3/7/2024 |
1.2.6 | 75 | 3/7/2024 |
1.2.5 | 181 | 3/3/2024 |
1.2.4 | 130 | 3/3/2024 |
1.2.3 | 138 | 3/1/2024 |
1.2.2 | 77 | 2/26/2024 |
1.2.1 | 74 | 2/26/2024 |
1.2.0 | 118 | 2/26/2024 |
1.1.8-prerelease | 116 | 2/24/2023 |
1.1.6-prerelease | 92 | 2/19/2023 |
1.1.5-prerelease | 122 | 2/14/2023 |
1.1.1-prerelease | 86 | 2/13/2023 |
1.1.0-prerelease | 261 | 11/6/2022 |
1.0.9-prerelease | 102 | 11/6/2022 |
1.0.8-prerelease | 125 | 6/9/2022 |
1.0.7-prerelease | 131 | 6/7/2022 |
1.0.6-prerelease | 128 | 6/3/2022 |
1.0.5-prerelease | 126 | 5/31/2022 |
1.0.3-prerelease | 131 | 4/4/2022 |
1.0.2-prerelease | 196 | 4/3/2022 |