Exemplo n.º 1
0
        public static async Task Main(string[] args)
        {
            var eventStore = new JsonFileEventStore("ExampleEvents.zip", 100);

            IDocumentStore documentStore = BuildDocumentStore();

            var dispatcher = new Dispatcher(eventStore.Subscribe);

            IStartableModule module = null;

            IWebHostBuilder hostBuilder = WebHost
                                          .CreateDefaultBuilder(args)
                                          .UseUrls("http://*:9000")
                                          .ConfigureServices(services =>
            {
            })
                                          .Configure(appBuilder =>
            {
                module = appBuilder.UseDocumentStatisticsModule(documentStore, dispatcher);
            });


            using (var host = hostBuilder.Build())
            {
                host.Start();
                await module.Start();

                Console.WriteLine("The statistics module is running. ");
                Console.WriteLine($"Try http://localhost:9000/Statistics/CountsPerState?country=6df7e2ac-6f06-420a-a0b5-14fb3865e850&kind=permit");
                Console.WriteLine($"Examine the Raven DB at http://localhost:9001");

                Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            var container = TinyIoCContainer.Current;

            string executionFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            var eventStore = new JsonFileEventStore(Path.Combine(executionFolder, "ExampleEvents.zip"), 100);

            IDocumentStore store = BuildDocumentStore(".\\", 9001);

            container.Register <Func <IAsyncDocumentSession> >(() => store.OpenAsyncSession());
            var dispatcher = new Dispatcher(eventStore.Subscribe);

            var bootstrapper = new CountsProjector(dispatcher, store.OpenAsyncSession);

            var startOptions = new StartOptions($"http://localhost:9000");

            using (WebApp.Start(startOptions, builder => builder.UseControllers(container)))
            {
                bootstrapper.Start().Wait();

                Console.WriteLine($"HTTP API is available at http://localhost:9000/api/Statistics/CountsPerState?country=f57835c6-a818-49c0-bcb5-ab770243bb7a&kind=Permit");
                Console.WriteLine($"Management Studio available at http://localhost:9001");

                Console.ReadLine();
            }
        }
Exemplo n.º 3
0
        public static async Task Main(string[] args)
        {
            IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
                                       .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup <Startup>();
                webBuilder.UseUrls("http://*:9000");
                webBuilder.ConfigureServices(sc =>
                {
                    var eventStore = new JsonFileEventStore("ExampleEvents.zip", 100);
                    var dispatcher = new Dispatcher(eventStore.Subscribe);
                    sc.AddSingleton(dispatcher);

                    sc.AddSingleton <IDocumentStore>(BuildDocumentStore());
                });
            });

            using var host = hostBuilder.Build();

            Console.WriteLine("The statistics module is running. ");
            Console.WriteLine(
                $"Try http://localhost:9000/Statistics/Metrics/CountsPerState?country=6df7e2ac-6f06-420a-a0b5-14fb3865e850&kind=permit");
            Console.WriteLine($"Examine the Raven DB at http://localhost:9001");

            await host.RunAsync();
        }