Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit e95774d

Browse files
further log refactoring
1 parent dbfd6bb commit e95774d

File tree

3 files changed

+106
-160
lines changed

3 files changed

+106
-160
lines changed

src/SqlStreamStore.Server/SqlStreamStoreFactory.cs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,7 @@ public IStreamStore Create()
4141
}
4242
}
4343

44-
public InMemoryStreamStore CreateInMemoryStreamStore()
45-
{
46-
if (_configuration.Schema != default)
47-
{
48-
LogNotSupported(mysql, nameof(_configuration.Schema));
49-
}
50-
51-
if (_configuration.DisableDeletionTracking)
52-
{
53-
LogNotSupported(mysql, nameof(_configuration.DisableDeletionTracking));
54-
}
55-
56-
return new InMemoryStreamStore();
57-
}
44+
public InMemoryStreamStore CreateInMemoryStreamStore() => new InMemoryStreamStore();
5845

5946
public MsSqlStreamStoreV3 CreateMsSqlStreamStore()
6047
{
@@ -72,17 +59,10 @@ public MsSqlStreamStoreV3 CreateMsSqlStreamStore()
7259
}
7360

7461
public MySqlStreamStore CreateMySqlStreamStore()
75-
{
76-
if (_configuration.Schema != default)
77-
{
78-
LogNotSupported(mysql, nameof(_configuration.Schema));
79-
}
80-
81-
return new MySqlStreamStore(new MySqlStreamStoreSettings(_configuration.ConnectionString)
62+
=> new MySqlStreamStore(new MySqlStreamStoreSettings(_configuration.ConnectionString)
8263
{
8364
DisableDeletionTracking = _configuration.DisableDeletionTracking
8465
});
85-
}
8666

8767
public PostgresStreamStore CreatePostgresStreamStore()
8868
{
@@ -98,11 +78,5 @@ public PostgresStreamStore CreatePostgresStreamStore()
9878

9979
return new PostgresStreamStore(settings);
10080
}
101-
102-
private static void LogNotSupported(string provider, string configurationKey) =>
103-
s_Log.Warning(
104-
"Configuration key '{configurationKey}' is not supported for provider {provider}. It will be ignored.",
105-
configurationKey,
106-
provider);
10781
}
10882
}

src/SqlStreamStore.Server/SqlStreamStoreServer.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Serilog;
77
using Serilog.Events;
88
using SqlStreamStore.HAL;
9+
using static SqlStreamStore.Server.Constants;
910

1011
namespace SqlStreamStore.Server
1112
{
@@ -42,6 +43,34 @@ private SqlStreamStoreServer(SqlStreamStoreServerConfiguration configuration)
4243

4344
s_Log.Information(configuration.ToString());
4445

46+
switch (configuration.Provider)
47+
{
48+
case inmemory:
49+
if (configuration.ConnectionString != default)
50+
{
51+
ConfigurationNotSupported(inmemory, nameof(_configuration.ConnectionString));
52+
}
53+
54+
if (configuration.Schema != default)
55+
{
56+
ConfigurationNotSupported(inmemory, nameof(_configuration.Schema));
57+
}
58+
59+
if (configuration.DisableDeletionTracking)
60+
{
61+
ConfigurationNotSupported(inmemory, nameof(_configuration.DisableDeletionTracking));
62+
}
63+
64+
break;
65+
case mysql:
66+
if (configuration.Schema != default)
67+
{
68+
ConfigurationNotSupported(mysql, nameof(_configuration.Schema));
69+
}
70+
71+
break;
72+
}
73+
4574
_configuration = configuration;
4675
_cts = new CancellationTokenSource();
4776
_factory = new SqlStreamStoreFactory(configuration);
@@ -105,6 +134,12 @@ private Task RunInitialization()
105134
private Task RunDatabaseInitialization()
106135
=> new DatabaseInitializer(_configuration).Initialize(_cts.Token);
107136

137+
private static void ConfigurationNotSupported(string provider, string configurationKey) =>
138+
s_Log.Warning(
139+
"Configuration key '{configurationKey}' is not supported for provider {provider}. It will be ignored.",
140+
configurationKey,
141+
provider);
142+
108143
public void Dispose()
109144
{
110145
_cts?.Dispose();

0 commit comments

Comments
 (0)