-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathProgram.cs
49 lines (37 loc) · 1.12 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Orleans;
using Orleans.Hosting;
using Orleankka;
using Orleankka.Cluster;
using static System.Console;
namespace Demo
{
[Serializable, GenerateSerializer]
public class Greet
{
[Id(0)] public string Who { get; set; }
}
public interface IGreeter : IActorGrain, IGrainWithStringKey {}
public class Greeter : DispatchActorGrain, IGreeter
{
void On(Greet msg) => WriteLine($"Hello, {msg.Who}!");
}
public static class Program
{
public static async Task Main()
{
WriteLine("Running example. Booting cluster might take some time ...\n");
var host = new HostBuilder()
.UseOrleans(c => c.UseLocalhostClustering())
.UseOrleankka()
.Build();
await host.StartAsync();
var greeter = host.ActorSystem().ActorOf<IGreeter>("id");
await greeter.Tell(new Greet {Who = "world"});
Write("\n\nPress any key to terminate ...");
ReadKey(true);
}
}
}