예제 #1
0
        public SqlStreamStoreFactory(SqlStreamStoreServerConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            _configuration = configuration;
        }
        public DatabaseInitializer(SqlStreamStoreServerConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            _configuration = configuration;
        }
        public static async Task <int> Main(string[] args)
        {
            var configuration = new SqlStreamStoreServerConfiguration(
                Environment.GetEnvironmentVariables(),
                args);

            using (var server = new SqlStreamStoreServer(configuration))
            {
                return(await server.Run());
            }
        }
        private SqlStreamStoreServer(SqlStreamStoreServerConfiguration configuration)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Is(configuration.LogLevel)
                         .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
                         .Enrich.FromLogContext()
                         .WriteTo.Console(
                outputTemplate:
                "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}")
                         .CreateLogger();

            s_Log.Information(configuration.ToString());

            switch (configuration.Provider)
            {
            case inmemory:
                if (configuration.ConnectionString != default)
                {
                    ConfigurationNotSupported(inmemory, nameof(_configuration.ConnectionString));
                }

                if (configuration.Schema != default)
                {
                    ConfigurationNotSupported(inmemory, nameof(_configuration.Schema));
                }

                if (configuration.DisableDeletionTracking)
                {
                    ConfigurationNotSupported(inmemory, nameof(_configuration.DisableDeletionTracking));
                }

                break;

            case mysql:
                if (configuration.Schema != default)
                {
                    ConfigurationNotSupported(mysql, nameof(_configuration.Schema));
                }

                break;
            }

            _configuration = configuration;
            _cts           = new CancellationTokenSource();
            _factory       = new SqlStreamStoreFactory(configuration);
        }