Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
.vscode/
artifacts/
build.sh
build.cmd
build.cmd
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ env:
- secure: fKxyki9JzY95G17hNHSy4dgDmH+zXIk50BR6honAz7LmsA9jGv2gg+l1AIUERH3eckdJwxze4K0e5hX88Xfn4j5nN8TnEw7Wwn7c1vjR9FxvRr5cjaJC0SVsOTZj4VC1R9Sqjzrkqv3jJDtDdz9B8aZMdEzJ+BkHwUMFxmuko2p2qabKnAonaGk5VDSTtDyvDMa0aFjKDYuB6MrnrxhfCzLk1ciyGL61SNfz0/u7Hj3xC6v4U0f0BQ9n65l5dIVn+mpuCdQ7GO0HGj0ySo7ffif3qqXXTx7ZWIl3wvf5RCp0PouA8q2dRHYYyGqhhCwuRNU7dfhS/eFtUtcITclZ/DJE86NBQGJ9tpUUhL7BJ3sNJZzbajh1F28paJgi595SKpScp4VGx3iBuDSKH4eb3cRj5TJqCUoscue8/uIZGgR4PGkGF4lbad3b7xexIk1YY/2Rwun1J0N7tqS0rej3ZRZBtipMF64NrVnt9dZzgsIlssZ0W2NvG0vcLX6DUdeZaR0diz8bUl1DXrMFxAUQ/QYxilvaESmCslRElzlb+5eaqQTG5lSP5l6f3ZcKAhvcUGggu9t3vjzpEq3zFa5dorCyK+es1ASNlwZtZr8in9oYkvam9aiDkZD8cEc+9u+qxvnX9w3MsA0P047YCMQGgwRl5dpizoySC3wr52voK7I=
- secure: HvSSWjsLR6qFi9/iHMKKoVUT4BDN7h4QjKHLvcrznwpfojrA1+nIlIwgcaIkxi5WClsoPmwW8YInPlyIyV+37+SaNK4sxB2puzwaC3iHBi6Ql38q+olsLdCE8u+DcfEcnzQo8pinNoyBLRjBgHjTAbrwIkLETNOZchss4A4UVhvPSznuNz5imlZxp4LqZ2pW/YcaLeCMQzuJHt5iRM6O4CMu7O4kMP/SPQXIXcqqYWI+o4um1JFO5juXBXtrhcTkOHfvGjqZghwma1F3v7zLHtqrbGBxaTLGNj0EIWPQhQEE5wDpvAqLEZcySl0ZjsPQUJd2Uxi9b8mWM1x6WaZTu9uqIy5t9lkCwUkEAwc/LUXZxwL0oi8HncgJvu7Q5KwVn375sJ0CER0Vn1FO8jphnMbpfkqUmbZmkwoIAUENNNYyGEp6zoNnRvaFQTjEW4bL2huPS0g3BgC2xyh8d5ZsPykIgQXlM8EEA2BZkd+ep2rKjOPT94rs5V5IPuVi9FYzFIsc2kpEkKZO/38j6pEAdCVIZp1m0+KRlLNQ9FeaI+xtil95V5ALIEXpc44o5OuUSoxt5ZirYaGSJtUtxo8E+HqpNL5WrTUeE8+aZos6Tu7jF63U2ehwg5xR6EubvrBjWvSHsQKcwDfdeHK2m15S/mVlahpwyyoCASAJtV7mRJI=
matrix:
- LIBRARY_VERSION=1.2.0-beta.3.19 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=alpine3.9 RUNTIME=alpine-x64
- LIBRARY_VERSION=1.2.0-beta.3.19 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=alpine3.8 RUNTIME=alpine-x64
- LIBRARY_VERSION=1.2.0-beta.3.19 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=bionic RUNTIME=ubuntu.18.04-x64
- LIBRARY_VERSION=1.2.0-beta.3.19 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=stretch-slim RUNTIME=debian.9-x64
- LIBRARY_VERSION=1.2.0-beta.3.21 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=alpine3.9 RUNTIME=alpine-x64
- LIBRARY_VERSION=1.2.0-beta.3.21 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=alpine3.8 RUNTIME=alpine-x64
- LIBRARY_VERSION=1.2.0-beta.3.21 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=bionic RUNTIME=ubuntu.18.04-x64
- LIBRARY_VERSION=1.2.0-beta.3.21 CONTAINER_RUNTIME_VERSION=2.2.4 CONTAINER_RUNTIME=stretch-slim RUNTIME=debian.9-x64
git:
depth: false
33 changes: 33 additions & 0 deletions examples/docker-compose-mysql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.1'

services:
sql-stream-store:
container_name: sss-example-server
#image: sqlstreamstore/server:1.2.0-beta.3.21-alpine3.9
image: sql-stream-store-server
ports:
- "5000:80"
networks:
- app-network
- db-network
environment:
- SQLSTREAMSTORE_PROVIDER=mysql
- SQLSTREAMSTORE_CONNECTION_STRING=Host=database;Port=3306;User Id=root;Database=example;Pooling=false;
depends_on:
- database

database:
container_name: sss-example-mysql
image: mysql:5.6
ports:
- "3306:3306"
networks:
- db-network
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=1

networks:
app-network:
driver: bridge
db-network:
driver: bridge
3 changes: 2 additions & 1 deletion src/SqlStreamStore.Server/SqlStreamStore.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<LangVersion>latest</LangVersion>
<CrossGenDuringPublish>false</CrossGenDuringPublish>
<LibraryVersion Condition="$(LibraryVersion) == ''">1.2.0-beta.3.21+build.442</LibraryVersion>
<LibraryVersion Condition="$(LibraryVersion) == ''">1.2.0-beta.3.21</LibraryVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ILLink.Tasks" Version="0.1.5-preview-1841731" />
Expand All @@ -18,6 +18,7 @@
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="SqlStreamStore.MsSql" Version="$(LibraryVersion)" />
<PackageReference Include="SqlStreamStore.MySql" Version="$(LibraryVersion)" />
<PackageReference Include="SqlStreamStore.Postgres" Version="$(LibraryVersion)" />
<PackageReference Include="SqlStreamStore.HAL" Version="$(LibraryVersion)" />
</ItemGroup>
Expand Down
43 changes: 42 additions & 1 deletion src/SqlStreamStore.Server/SqlStreamStoreFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using Npgsql;
using Serilog;
using SqlStreamStore.Infrastructure;
Expand All @@ -21,14 +22,16 @@ private delegate Task<IStreamStore> CreateStreamStore(

private const string postgres = nameof(postgres);
private const string mssql = nameof(mssql);
private const string mysql = nameof(mysql);
private const string inmemory = nameof(inmemory);

private static readonly IDictionary<string, CreateStreamStore> s_factories
= new Dictionary<string, CreateStreamStore>
{
[inmemory] = CreateInMemoryStreamStore,
[postgres] = CreatePostgresStreamStore,
[mssql] = CreateMssqlStreamStore
[mssql] = CreateMssqlStreamStore,
[mysql] = CreateMySqlStreamStore
};

public SqlStreamStoreFactory(SqlStreamStoreServerConfiguration configuration)
Expand Down Expand Up @@ -110,6 +113,44 @@ CREATE DATABASE [{connectionStringBuilder.InitialCatalog}]
return streamStore;
}

private static async Task<IStreamStore> CreateMySqlStreamStore(
string connectionString,
string _,
CancellationToken cancellationToken)
{
var connectionStringBuilder = new MySqlConnectionStringBuilder(connectionString);
var settings = new MySqlStreamStoreSettings(connectionString);

var streamStore = new MySqlStreamStore(settings);

try
{
using (var connection = new MySqlConnection(new MySqlConnectionStringBuilder(connectionString)
{
Database = null
}.ConnectionString))
{
await connection.OpenAsync(cancellationToken).NotOnCapturedContext();

using (var command = new MySqlCommand(
$"CREATE DATABASE IF NOT EXISTS `{connectionStringBuilder.Database}`",
connection))
{
await command.ExecuteNonQueryAsync(cancellationToken).NotOnCapturedContext();
}
}

await streamStore.CreateSchemaIfNotExists(cancellationToken);
}
catch (SqlException ex)
{
SchemaCreationFailed(streamStore.GetSchemaCreationScript, ex);
throw;
}

return streamStore;
}

private static async Task<IStreamStore> CreatePostgresStreamStore(
string connectionString,
string schema,
Expand Down