forked from OrleansContrib/Orleankka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
73 lines (58 loc) · 1.99 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Reflection;
using System.Threading.Tasks;
using Orleankka;
using Orleankka.Meta;
using Orleankka.Playground;
namespace Example
{
public static class Program
{
public static void Main()
{
Console.WriteLine("Make sure you've started local GES node using \".\\Nake.bat run\"!");
Console.WriteLine("Running example. Booting cluster might take some time ...\n");
var system = ActorSystem.Configure()
.Playground()
.Cluster(x => x.Bootstrapper<ES.Bootstrap>())
.Assemblies(Assembly.GetExecutingAssembly())
.Done();
system.Start().Wait();
try
{
Run(system).Wait();
}
catch (AggregateException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.InnerException.Message);
}
Console.WriteLine("\nPress any key to terminate ...");
Console.ReadKey(true);
system.Dispose();
Environment.Exit(0);
}
static async Task Run(IActorSystem system)
{
var item = system.ActorOf<InventoryItem>("12345");
await item.Tell(new Create("XBOX1"));
await Print(item);
await item.Tell(new CheckIn(10));
await Print(item);
await item.Tell(new CheckOut(5));
await Print(item);
await item.Tell(new Rename("XBOX360"));
await Print(item);
await item.Tell(new Deactivate());
await Print(item);
}
static async Task Print(ActorRef item)
{
var details = await item.Ask(new GetDetails());
Console.WriteLine("{0}: {1} {2}",
details.Name,
details.Total,
details.Active ? "" : "(deactivated)");
}
}
}