Collection of Microsoft Orleans libraries and files needed on the client.
$ dotnet add package Microsoft.Orleans.ClientMicrosoft Orleans Client is a metapackage that includes all the necessary components to connect to an Orleans cluster from a client application. It provides a simplified way to set up an Orleans client by providing a single package reference rather than requiring you to reference multiple packages individually.
To use this package, install it via NuGet:
dotnet add package Microsoft.Orleans.Client
using Microsoft.Extensions.Hosting;
using Orleans;
using Orleans.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
namespace ExampleGrains;
// Define a grain interface
public interface IMyGrain : IGrainWithStringKey
{
Task<string> DoSomething();
}
// Create a client
var builder = Host.CreateApplicationBuilder(args)
.UseOrleansClient(client =>
{
client.UseLocalhostClustering();
});
var host = builder.Build();
await host.StartAsync();
// Get a reference to a grain and call it
var client = host.Services.GetRequiredService<IClusterClient>();
var grain = client.GetGrain<IMyGrain>("my-grain-id");
var result = await grain.DoSomething();
// Print the result
Console.WriteLine($"Result: {result}");
// Keep the host running until the application is shut down
await host.WaitForShutdownAsync();
For more comprehensive documentation, please refer to: