Beispiel #1
0
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");
            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();
            var consumerClient              = result.Container.Get <IConsumerClient>();
            var microservices               = result.Container.Get <IMicroservices>();
            var executionContextManager     = result.Container.Get <IExecutionContextManager>();
            var boundedContextConfiguration = result.Container.Get <BoundedContextConfiguration>();

            executionContextManager.CurrentFor(boundedContextConfiguration.Application, boundedContextConfiguration.BoundedContext, TenantId.Development);
            var eventHorizon = new EventHorizon.EventHorizon(
                executionContextManager.Current.Microservice,
                executionContextManager.Current.Tenant,
                Guid.Parse("4e146c23-3b32-4eae-90bd-068f37844dc0"),
                TenantId.Development);
            var microserviceAddress = microservices.GetAddressFor(eventHorizon.ProducerMicroservice);

            _ = consumerClient.SubscribeTo(eventHorizon, Guid.Parse("8a37fe70-654e-4e47-91e6-0c9103bd0519"), Guid.Parse("db7acf1e-a640-41f3-934f-f2f188e1b1e9"), Guid.Empty, microserviceAddress);
            await host.RunAsync().ConfigureAwait(false);
        }
Beispiel #2
0
        static async Task Main(string[] args)
        {
            // Standard .NET Core Host
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ =>
            {
                _.AddConsole();
            });
            hostBuilder.UseEnvironment("Development");
            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            // Boot Dolittle
            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();

            // Get our IFoo service
            var foo = result.Container.Get <IFoo>();

            await host.RunAsync();
        }
Beispiel #3
0
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");
            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();

            var logger = result.Container.Get <Dolittle.Logging.ILogger>();

            logger.Information("Booted");

            // await HeadConnectionLifecycle.Connected.ConfigureAwait(false);
            var commandContextManager   = result.Container.Get <ICommandContextManager>();
            var executionContextManager = result.Container.Get <IExecutionContextManager>();
            var commandCoordinator      = result.Container.Get <ICommandCoordinator>();

            executionContextManager.CurrentFor(TenantId.Development);

            logger.Information("Handle command");

            var commandResult = commandCoordinator.Handle(new MyCommand());

            logger.Information("Success : {Result}", commandResult.Success);

            await host.RunAsync().ConfigureAwait(false);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var before = DateTime.Now;

            Console.WriteLine("Start Dolittle");

            var bootResult = Bootloader.Configure(_ => _
                                                  .WithEntryAssembly(typeof(Program).Assembly)
                                                  .WithAssembliesSpecifiedIn(typeof(Program).Assembly)
                                                  .SynchronousScheduling()
                                                  .NoLogging()
                                                  //.UseLogAppender(new CustomLogAppender())
                                                  ).Start();

            var container = bootResult.Container;
            var logger    = container.Get <ILogger>();
            var after     = DateTime.Now;
            var delta     = after.Subtract(before);

            Console.WriteLine($"We're running - took {delta.TotalSeconds}");

            var executionContextManager = container.Get <IExecutionContextManager>();

            executionContextManager.CurrentFor(TenantId.Development);

            var interop = container.Get <IJSRuntime>();

            interop.Invoke("window._dolittleLoaded");
        }
Beispiel #5
0
        static void SetupHost()
        {
            var loggerFactory = new LoggerFactory(new ILoggerProvider[]
            {
                new NullLoggerProvider()
            });

            _bootLoaderResult = Bootloader.Configure(_ => _
                                                     .UseLoggerFactory(loggerFactory)
                                                     .UseLogAppender(new NullLogAppender())
                                                     .SkipBootprocedures()
                                                     ).Start();
        }
Beispiel #6
0
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");

            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();
            var logger = result.Container.Get <Dolittle.Logging.ILogger>();

            var client   = result.Container.Get <TestServiceClient>();
            var response = await client.SayHelloToAsync(new Request { Name = "Yoda" });

            logger.Information($"Response was : {response.Message}");

            var counter = 0;
            var stream  = client.SayHelloToStream()
                          var timer = new System.Timers.Timer(1000);

            timer.Elapsed += (s, e) => stream.RequestStream.WriteAsync(new Request {
                Name = $"R2-D{counter++}"
            });
            timer.Start();

            var task = Task.Run(async() =>
            {
                while (await stream.ResponseStream.MoveNext(CancellationToken.None).ConfigureAwait(false))
                {
                    logger.Information($"Response : {stream.ResponseStream.Current.Message}");
                }
            });

            await host.RunAsync().ConfigureAwait(false);

            timer.Dispose();

            loggerFactory.Dispose();
        }
Beispiel #7
0
        /// <summary>
        /// Adds Dolittle services
        /// </summary>
        /// <returns></returns>
        public static BootloaderResult AddDolittle(this IServiceCollection services, Action <IBootBuilder> builderDelegate)
        {
            var bootloader = Bootloader.Configure(_ => {
                if (EnvironmentUtilities.GetExecutionEnvironment() == Dolittle.Execution.Environment.Development)
                {
                    _ = _.Development();
                }
                _.SkipBootprocedures()
                .UseContainer <Container>();
                builderDelegate(_);
            });

            var bootloaderResult = bootloader.Start();

            AddMvcOptions(services, bootloaderResult.TypeFinder);

            return(bootloaderResult);
        }
Beispiel #8
0
        static void Main()
        {
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddConsole();

            var bootloader = Bootloader.Configure(_ => _
                                                  .UseLoggerFactory(loggerFactory)
                                                  .Development()
                                                  .IncludeAssembliesStartingWith("Microsoft"));

            var result = bootloader.Start();
            var logger = result.Container.Get <ILogger>();

            result.Assemblies.GetAll().ForEach(_ => logger.Information($"Assembly '{_}' loaded and part of discovery"));

            loggerFactory.Dispose();
        }
        /// <inheritdoc/>
        public ContainerBuilder CreateBuilder(IServiceCollection services)
        {
            ApplyLoggerFactoryWorkarounds(services);

            var builder = _autofacFactory.CreateBuilder(services);

            var bootResult = Bootloader.Configure(_ =>
            {
                if (_context.HostingEnvironment.IsDevelopment())
                {
                    _.Development();
                }
                _.SkipBootprocedures();
                _.UseContainer <ServiceProviderContainer>();
            }).Start();

            builder.AddDolittle(bootResult.Assemblies, bootResult.Bindings);

            return(builder);
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            var logger = new LogAppender();

            logger.MinimumLevel = LogLevel.Warning;

            var bootResult = Bootloader.Configure(_ =>
            {
                _.UseLogAppender(logger);
            }).Start();

            var container = bootResult.Container;
            var manager   = container.Get <IExecutionContextManager>();

            manager.CurrentFor(TenantId.Development);
            var command = container.Get <Command>();

            logger.MinimumLevel = LogLevel.Trace;
            command.Run();
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            var before = DateTime.Now;

            var bootResult = Bootloader.Configure(_ => _
                                                  .WithEntryAssembly(typeof(Program).Assembly)
                                                  .WithAssembliesSpecifiedIn(typeof(Program).Assembly)
                                                  .SynchronousScheduling()
                                                  .UseLogAppender(new CustomLogAppender())
                                                  ).Start();

            var container = bootResult.Container;
            var logger    = container.Get <ILogger>();

            logger.Information("We're running");

            //SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_WebAssembly());

            //SampleClass.Run().Wait();
        }
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");

            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();

            await host.RunAsync().ConfigureAwait(false);

            loggerFactory.Dispose();
        }
Beispiel #13
0
        /// <summary>
        /// Adds Dolittle services
        /// </summary>
        /// <returns></returns>
        public static BootloaderResult AddDolittle(this IServiceCollection services, ILoggerFactory loggerFactory = null)
        {
            var bootloader = Bootloader.Configure(_ => {
                if (loggerFactory != null)
                {
                    _ = _.UseLoggerFactory(loggerFactory);
                }
                if (EnvironmentUtilities.GetExecutionEnvironment() == Dolittle.Execution.Environment.Development)
                {
                    _ = _.Development();
                }
                _.SkipBootprocedures()
                .UseContainer <Container>();
            });

            var bootloaderResult = bootloader.Start();

            AddMvcOptions(services, bootloaderResult.TypeFinder);

            return(bootloaderResult);
        }
Beispiel #14
0
        static int Main(string[] args)
        {
            try
            {
                var startTime = DateTime.UtcNow;

                var assemblyFile       = args[0];
                var pluginAssemblies   = args[1].Split(";");
                var configurationFile  = args[2];
                var outputAssemblyFile = args[3];

                if (string.IsNullOrEmpty(args[1]) ||
                    pluginAssemblies.Length == 0 ||
                    string.IsNullOrEmpty(configurationFile))
                {
                    return(0);
                }

                var assembly        = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyFile);
                var assemblyContext = AssemblyContext.From(assemblyFile);
                BuildTarget = new BuildTarget(assemblyFile, outputAssemblyFile, assembly, assemblyContext);

                Console.WriteLine("Performing Dolittle post-build steps");

                Console.WriteLine($"  Performing for: {assemblyFile}");
                Console.WriteLine($"  Will output to: {outputAssemblyFile}");
                Console.WriteLine("  Using plugins from: ");

                foreach (var pluginAssembly in pluginAssemblies)
                {
                    Console.WriteLine($"    {pluginAssembly}");
                }

                var bootLoaderResult = Bootloader.Configure(_ => _
                                                            .WithAssemblyProvider(new AssemblyProvider(new Dolittle.Logging.NullLogger(), pluginAssemblies))
                                                            .NoLogging()
                                                            .SkipBootprocedures()
                                                            ).Start();

                var buildMessages = bootLoaderResult.Container.Get <IBuildMessages>();

                var configuration = bootLoaderResult.Container.Get <IPerformerConfigurationManager>();
                configuration.Initialize(configurationFile);
                var buildTaskPerformers = bootLoaderResult.Container.Get <IBuildTaskPerformers>();
                buildTaskPerformers.Perform();

                var assemblyModifiers = bootLoaderResult.Container.Get <ITargetAssemblyModifiers>();
                assemblyModifiers.ModifyAndSave();

                var postTasksPerformers = bootLoaderResult.Container.Get <IPostBuildTaskPerformers>();
                postTasksPerformers.Perform();

                var endTime   = DateTime.UtcNow;
                var deltaTime = endTime.Subtract(startTime);
                buildMessages.Information($"Time Elapsed {deltaTime.ToString("G")} (Dolittle)");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error executing Dolittle post build tool".Red());
                Console.Error.WriteLine($"Exception: {ex.Message}".Red());
                Console.Error.WriteLine($"StackTrace: {ex.StackTrace}".Red());
                return(1);
            }

            return(0);
        }
Beispiel #15
0
 static void Main()
 {
     Bootloader.Configure(_ => { }).Start().Wait();
 }
Beispiel #16
0
 public static ISobaScript MakeNew(IUVars uvars, IEnvironment env)
 => Bootloader.Configure(new Soba(uvars), env);
Beispiel #17
0
 static void Main(string[] args)
 {
     Bootloader.Configure(_ => {}).Start().Wait();
 }