public Scope(IServiceCollection services, PerfTimer timer = null) { if (timer == null) { Bootstrapping = new PerfTimer(); Bootstrapping.Start("Bootstrapping Container"); } else { Bootstrapping = timer; Bootstrapping.MarkStart("Lamar Scope Creation"); } Root = this; Bootstrapping.MarkStart("Build ServiceGraph"); ServiceGraph = new ServiceGraph(services, this); Bootstrapping.MarkFinished("Build ServiceGraph"); ServiceGraph.Initialize(Bootstrapping); if (timer == null) { Bootstrapping.Stop(); } else { Bootstrapping.MarkFinished("Lamar Scope Creation"); } }
public async Task Activate(LocalWorkerSender localWorker, CapabilityGraph capabilities, JasperRuntime runtime, GenerationRules generation, PerfTimer timer) { timer.MarkStart("ServiceBusActivator"); _handlers.Compile(generation, runtime, timer); var capabilityCompilation = capabilities.Compile(_handlers, Serialization, _channels, runtime, _transports, Lookup); var transports = _transports.Where(x => _settings.StateFor(x.Protocol) != TransportState.Disabled) .ToArray(); timer.Record("WorkersGraph.Compile", () => { _settings.Workers.Compile(_handlers.Chains.Select(x => x.MessageType)); }); localWorker.Start(_persistence, Workers); if (!_settings.DisableAllTransports) { timer.MarkStart("ApplyLookups"); await _settings.ApplyLookups(Lookup); timer.MarkFinished("ApplyLookups"); timer.Record("ChannelGraph.Start", () => { _channels.As <ChannelGraph>().Start(_settings, transports, Lookup, capabilities, Logger, Workers); }); ScheduledJobs.Start(Workers); } runtime.Capabilities = await capabilityCompilation; if (runtime.Capabilities.Errors.Any() && _settings.ThrowOnValidationErrors) { throw new InvalidSubscriptionException(runtime.Capabilities.Errors); } timer.MarkFinished("ServiceBusActivator"); }
private static async Task <JasperRuntime> bootstrap(JasperRegistry registry) { if (registry.Logging.UseConsoleLogging) { registry.Services.AddTransient <IMessageLogger, ConsoleMessageLogger>(); registry.Services.AddTransient <ITransportLogger, ConsoleTransportLogger>(); } var timer = new PerfTimer(); timer.Start("Bootstrapping"); timer.Record("Finding and Applying Extensions", () => { applyExtensions(registry); }); timer.Record("Bootstrapping Settings", () => registry.Settings.Bootstrap()); var handlerCompilation = registry.Bus.CompileHandlers(registry, timer); var services = registry.CombinedServices(); var runtime = new JasperRuntime(registry, services, timer); var featureBuilding = registry.BuildFeatures(runtime, timer); await handlerCompilation; await registry.Bus.Activate(runtime, registry.Generation, timer); await featureBuilding; await registry.Startup(runtime); // Run environment checks timer.Record("Environment Checks", () => { var recorder = EnvironmentChecker.ExecuteAll(runtime); if (runtime.Get <BusSettings>().ThrowOnValidationErrors) { recorder.AssertAllSuccessful(); } }); timer.MarkStart("Register Node"); await registerRunningNode(runtime); timer.MarkFinished("Register Node"); timer.Stop(); return(runtime); }