Skip to content

Commit

Permalink
Adding bootstrap for sqld using basic master config, this will eventu…
Browse files Browse the repository at this point in the history
…ally become the entry point for a docker container
  • Loading branch information
RealOrko committed Oct 18, 2024
1 parent 15a3eea commit 1189c15
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/SqlD.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
using SqlD;

Interface.Setup(typeof(Program).Assembly, "appsettings.json");
Interface.Start();
Interface.Wait();
6 changes: 6 additions & 0 deletions src/SqlD.CLI/SqlD.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
<ProjectReference Include="..\sql-d\SqlD.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
52 changes: 52 additions & 0 deletions src/SqlD.CLI/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"Logging": {
"LogLevel": {
"System": "Error",
"Default": "Error",
"Microsoft": "Error"
}
},
"SqlD": {
"loglevel": "info",
"enabled": true,
"settings": {
"connections": {
"strategy": "singleton"
},
"forwarding": {
"allowed": true,
"strategy": "secondary"
},
"replication": {
"allowed": true,
"interval": 30,
"delay": 30
}
},
"registries": [],
"services": [
{
"name": "sql-d-master-1",
"database": "sql-d-master-1.db",
"host": "localhost",
"port": 50110,
"tags": [
"master"
],
"pragma": {
"journalMode": "OFF",
"synchronous": "OFF",
"tempStore": "OFF",
"lockingMode": "OFF",
"countChanges": "OFF",
"pageSize": "65536",
"cacheSize": "10000",
"queryOnly": "OFF",
"autoVacuum": "INCREMENTAL",
"autoVacuumPages": "64"
},
"forwardingTo": []
}
]
}
}
5 changes: 5 additions & 0 deletions src/sql-d/Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,9 @@ public enum InterfaceStopKind
All,
NotFoundInConfig
}

public static void Wait()
{
ConnectionListenerFactory.WaitAll();
}
}
2 changes: 1 addition & 1 deletion src/sql-d/Network/Client/ConnectionClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal static void DisposeAll()
Clients.Clear();
}

public static void DisposeNotInConfig(EndPoint[] optionalEndPoints)
internal static void DisposeNotInConfig(EndPoint[] optionalEndPoints)
{
foreach (var client in Clients.Values.ToList())
{
Expand Down
5 changes: 5 additions & 0 deletions src/sql-d/Network/Server/ConnectionListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public virtual void Dispose()

Log.Out.Info($"Disposed connection listener on {ServiceModel.ToUrl()}");
}

public void Wait()
{
_host.WaitForShutdown();
}
}
10 changes: 9 additions & 1 deletion src/sql-d/Network/Server/ConnectionListenerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static void DisposeAll()
Listeners.Clear();
}

public static void DisposeNotInConfig(EndPoint[] optionalEndPoints)
internal static void DisposeNotInConfig(EndPoint[] optionalEndPoints)
{
foreach (var listener in Listeners.Values.ToList())
{
Expand All @@ -53,4 +53,12 @@ public static void DisposeNotInConfig(EndPoint[] optionalEndPoints)

}
}

public static void WaitAll()
{
foreach (var listener in Listeners.Values.ToList())
{
listener.Wait();
}
}
}

0 comments on commit 1189c15

Please sign in to comment.