Esempio n. 1
0
        static void Main(string[] args)
        {
            var data = CsvLoader.Load("MOCK_DATA.csv");

            Console.WriteLine(data.Count());

            var serviceProvider = new ServiceCollection()
                                  .AddLogging()
                                  .BuildServiceProvider();

            _eventStream = EventStreamBuilder.Configure(config => config
                                                        .WithPersistantStore(_store)
                                                        .WithServiceFactory(serviceProvider)
                                                        .ScanAssemblyWithType <Program>())
                           .BuildWithProcessor(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(30));

            Console.WriteLine("Streaming events...");

            data.Select(x => new SiteVisited(x.Timestamp, x.IPAddress, x.UserName, x.Domain))
            .Select(x => _eventStream.Process(x));

            Console.WriteLine("Done receiving events");

            _eventStream.Shutdown();

            //var eventsStored = _store.GetEvents();
            // Console.WriteLine($"{eventsStored.Count()} events written to persistance store");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            _eventStream = EventStreamBuilder.Configure(c =>
            {
                c.WithPersistantStore(_store);
                c.ScanAssemblyWithType <Program>();
            })
                           .BuildWithProcessor(TimeSpan.FromMinutes(5));

            Console.WriteLine("Streaming events...");

            _eventStream
            .Process(new SensorOnline("CPU"))
            .Process(new SensorDataReceived(45.3m))
            .Process(new SensorDataReceived(42.6m))
            .Process(new SensorDataReceived(40.1m))
            .Process(new SensorDataReceived(40.1m))
            .Process(new SensorDataReceived(40.1m))
            .Process(new SensorDataReceived(39m))
            .Process(new SensorOffline())
            .Process(new SensorOnline("CPU"))
            .Process(new SensorDataReceived(40.5m))
            .Process(new SensorOffline());

            _eventStream.Shutdown();

            Console.WriteLine("Done receiving events");

            var eventsStored = _store.GetEvents();

            Console.WriteLine($"{eventsStored.Count()} events written to persistance store");
        }