Multicaster.Distributed.Redis
0.1.0
See the version list below for details.
dotnet add package Multicaster.Distributed.Redis --version 0.1.0
NuGet\Install-Package Multicaster.Distributed.Redis -Version 0.1.0
<PackageReference Include="Multicaster.Distributed.Redis" Version="0.1.0" />
paket add Multicaster.Distributed.Redis --version 0.1.0
#r "nuget: Multicaster.Distributed.Redis, 0.1.0"
// Install Multicaster.Distributed.Redis as a Cake Addin #addin nuget:?package=Multicaster.Distributed.Redis&version=0.1.0 // Install Multicaster.Distributed.Redis as a Cake Tool #tool nuget:?package=Multicaster.Distributed.Redis&version=0.1.0
Multicaster
This framework provides a proxy for transparently invoking methods of multiple POCO instances or remote clients through an interface.
For instance, a single call to IGreeter.Hello
can invoke methods on several objects or broadcast the call to remote clients like those using MagicOnion or SignalR.
The framework incorporates the concept of groups that bundle together the receivers (targets) to enable transparent invocation, allowing receivers to be added or removed flexibly from the group for ease of management.
Usage
In-Memory (Plain Old CLR Object)
public interface IGreeterReceiver
{
void OnMessage(string sender, string message);
}
public class GreeterReceiver(string name) : IGreeterReceiver
{
public void OnMessage(string sender, string message)
=> Console.WriteLine($"[{name}] <{sender}> {message}")
}
// Create receivers.
var receiverA = new GreeterReceiver("A");
var receiverIdA = Guid.NewGuid();
var receiverB = new GreeterReceiver("B");
var receiverIdB = Guid.NewGuid();
var receiverC = new GreeterReceiver("C");
var receiverIdC = Guid.NewGuid();
// Create a in-memory group provider.
var groupProvider = new InMemoryGroupProvider(DynamicInMemoryProxyFactory.Instance);
// Create a group and add receivers to the group.
var group = groupProvider.GetOrAddSynchronousGroup<IGreeterReceiver>("MyGroup");
group.Add(receiverIdA, receiverA);
group.Add(receiverIdB, receiverB);
group.Add(receiverIdC, receiverC);
// Call receivers via proxy.
group.All.OnMessage("System", "Hello");
group.Except([receiverIdA]).OnMessage("System", "Hello without A");
// Call the receiver directly. (Normal method call)
receiverA.OnMessage("DirectMessage", "Sent a message to the receiver directly.");
Outputs
[A] <System> Hello
[B] <System> Hello
[C] <System> Hello
[B] <System> Hello without A
[C] <System> Hello without A
[A] <DirectMessage> Sent a message to the receiver directly.
API
IMulticastGroupProvider
interface
IMulticastAsyncGroup<TReceiver> GetOrAddGroup<TReceiver>(string name);
IMulticastSyncGroup<TReceiver> GetOrAddSynchronousGroup<TReceiver>(string name);
IMulticastGroup<T>
interface
TReceiver All { get; }
TReceiver Except(ImmutableArray<Guid> excludes);
TReceiver Only(ImmutableArray<Guid> targets);
TReceiver Single(Guid target);
IMulticastAsyncGroup<T>
interface (implements IMulticastGroup<T>
)
ValueTask AddAsync(Guid key, TReceiver receiver, CancellationToken cancellationToken = default);
ValueTask RemoveAsync(Guid key, CancellationToken cancellationToken = default);
ValueTask<int> CountAsync(CancellationToken cancellationToken = default);
IMulticastSyncGroup<T>
interface (implements IMulticastGroup<T>
)
void Add(Guid key, TReceiver receiver);
void Remove(Guid key);
int Count();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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. |
-
net6.0
- MessagePack (>= 2.5.140)
- Microsoft.Extensions.Options (>= 8.0.2)
- Multicaster (>= 0.1.0)
- StackExchange.Redis (>= 2.7.33)
-
net8.0
- MessagePack (>= 2.5.140)
- Microsoft.Extensions.Options (>= 8.0.2)
- Multicaster (>= 0.1.0)
- StackExchange.Redis (>= 2.7.33)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Multicaster.Distributed.Redis:
Package | Downloads |
---|---|
MagicOnion.Server.Redis
Redis backplane for MagicOnion. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Multicaster.Distributed.Redis:
Repository | Stars |
---|---|
Cysharp/MagicOnion
Unified Realtime/API framework for .NET platform and Unity.
|