forked from OrleansContrib/Orleankka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (46 loc) · 1.55 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
50
51
52
53
54
55
56
57
58
using System;
using System.Reflection;
using System.Threading.Tasks;
using Autofac;
using Microsoft.Extensions.DependencyInjection;
using Orleankka;
using Orleankka.Playground;
namespace Example
{
using Properties;
class Program
{
public static void Main()
{
Console.WriteLine("Running example. Booting cluster might take some time ...\n");
var setup = new Action<ContainerBuilder>(builder =>
{
builder.RegisterType<SomeService>()
.AsImplementedInterfaces()
.WithParameter("connectionString", Settings.Default.ConnectionString)
.SingleInstance();
builder.RegisterType<DIActor>();
});
var system = ActorSystem
.Configure()
.Playground()
.Cluster(c => c
.Services(s => s
.AddSingleton<IActorActivator>(new AutofacActorActivator(setup))))
.Assemblies(Assembly.GetExecutingAssembly())
.Done();
system.Start().Wait();
Run(system).Wait();
Console.WriteLine("\nPress any key to terminate ...");
Console.ReadKey(true);
Environment.Exit(0);
}
static async Task Run(IActorSystem system)
{
var a = system.ActorOf<DIActor>("A-123");
var b = system.ActorOf<DIActor>("B-456");
await a.Tell("Hello");
await b.Tell("Bueno");
}
}
}