Пример #1
0
        private static async Task <JasperRuntime> bootstrap(JasperRegistry registry)
        {
            applyExtensions(registry);

            registry.Settings.Bootstrap();

            var features = registry.Features;

            var serviceRegistries = await Task.WhenAll(features.Select(x => x.Bootstrap(registry)))
                                    .ConfigureAwait(false);

            var collections = new List <IServiceCollection>();

            collections.AddRange(serviceRegistries);
            collections.Add(registry.ExtensionServices);
            collections.Add(registry.Services);


            var services = await ServiceCollectionExtensions.Combine(collections.ToArray());

            registry.Generation.ReadServices(services);


            var runtime = new JasperRuntime(registry, services);


            await Task.WhenAll(features.Select(x => x.Activate(runtime, registry.Generation)))
            .ConfigureAwait(false);

            return(runtime);
        }
Пример #2
0
        private static async Task <JasperRuntime> bootstrap(JasperRegistry registry)
        {
            applyExtensions(registry);

            registry.Settings.Bootstrap();

            var features = registry.Features;

            var serviceRegistries = await Task.WhenAll(features.Select(x => x.Bootstrap(registry)))
                                    .ConfigureAwait(false);

            var collections = new List <IServiceCollection>();

            collections.AddRange(serviceRegistries);
            collections.Add(registry.ExtensionServices);
            collections.Add(registry.Services);


            var services = await ServiceCollectionExtensions.Combine(collections.ToArray());

            registry.Generation.ReadServices(services);


            var runtime = new JasperRuntime(registry, services);

            registry.Http.As <IWebHostBuilder>().UseSetting(WebHostDefaults.ApplicationKey, registry.ApplicationAssembly.FullName);

            runtime.HttpAddresses = registry.Http.As <IWebHostBuilder>().GetSetting(WebHostDefaults.ServerUrlsKey);

            await Task.WhenAll(features.Select(x => x.Activate(runtime, registry.Generation)))
            .ConfigureAwait(false);

            // Run environment checks
            var recorder = EnvironmentChecker.ExecuteAll(runtime);

            if (runtime.Get <BusSettings>().ThrowOnValidationErrors)
            {
                recorder.AssertAllSuccessful();
            }

            await registerRunningNode(runtime);

            return(runtime);
        }
Пример #3
0
        private static async Task <JasperRuntime> bootstrap(JasperRegistry registry)
        {
            applyExtensions(registry);

            registry.Settings.Bootstrap();

            var features = registry.Features;

            var serviceRegistries = await Task.WhenAll(features.Select(x => x.Bootstrap(registry)))
                                    .ConfigureAwait(false);

            var collections = new List <IServiceCollection>();

            collections.AddRange(serviceRegistries);
            collections.Add(registry.ExtensionServices);
            collections.Add(registry.Services);


            var services = await ServiceCollectionExtensions.Combine(collections.ToArray());

            registry.Generation.ReadServices(services);


            var runtime = new JasperRuntime(registry, services);


            await Task.WhenAll(features.Select(x => x.Activate(runtime, registry.Generation)))
            .ConfigureAwait(false);

            // TODO -- THIS IS TEMPORARY UNTIL WE DO GH-212
            var hostedServices = runtime.Container.GetAllInstances <IHostedService>()
                                 .Select(x => x.StartAsync(CancellationToken.None));

            await Task.WhenAll(hostedServices);

            return(runtime);
        }