Beispiel #1
0
        private static async Task DoClientWork(Remote client, IRootContext context)
        {
            var index = 0;
            var verbs = new List <string>()
            {
                "Get",
                "Put",
                "Post"
            };
            var random  = new Random();
            var lastKey = "";
            PID pid     = null;

            // example of calling grains from the initialized client
            while (true)
            {
                var currentTime = DateTimeOffset.Now.ToString("g");
                var metric      = "latency";

                var currentKey = $"test!{currentTime}!{metric}";
                if (currentKey != lastKey)
                {
                    // This can be expensive
                    var result = await client.SpawnNamedAsync("127.0.0.1:8000", currentKey, "record",
                                                              TimeSpan.FromMinutes(30));

                    pid     = result.Pid;
                    lastKey = currentKey;
                }

                index++;
                if (index % 10_000 == 0)
                {
                    System.Threading.Thread.Sleep(100);
                    Console.WriteLine(index);
                }

                var r = new Record()
                {
                    Service     = "test",
                    Time        = (ulong)DateTimeOffset.Now.Ticks,
                    Metricvalue = 10
                };
                r.Attributes.Add("Verb", verbs[random.Next(0, 3)]);
                context.Send(pid, r);
            }
        }
 public virtual void Send(PID target, object message) => _context.Send(target, message);