1
0
mirror of synced 2024-11-22 01:13:49 +00:00

Merge branch 'release/1.0'

This commit is contained in:
Mark van Renswoude 2018-12-21 11:10:53 +01:00
commit ccf508c5df
13 changed files with 78 additions and 58 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti.Annotations</id>
<id>Tapeti.Annotations</id>
<version>$version$</version>
<title>Tapeti Annotations</title>
<authors>Mark van Renswoude</authors>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti.DataAnnotations</id>
<id>Tapeti.DataAnnotations</id>
<version>$version$</version>
<title>Tapeti DataAnnotations</title>
<authors>Mark van Renswoude</authors>
@ -14,7 +14,7 @@
<copyright></copyright>
<tags>rabbitmq tapeti dataannotations</tags>
<dependencies>
<dependency id="X2Software.Tapeti" version="[$version$]" />
<dependency id="Tapeti" version="[$version$]" />
<dependency id="System.ComponentModel.Annotations" version="4.5.0" />
</dependencies>
</metadata>

View File

@ -7,9 +7,9 @@ namespace Tapeti.Flow.SQL
{
public static class ConfigExtensions
{
public static TapetiConfig WithFlowSqlRepository(this TapetiConfig config, string connectionString, int serviceId, string schema = "dbo")
public static TapetiConfig WithFlowSqlRepository(this TapetiConfig config, string connectionString, string tableName = "Flow")
{
config.Use(new FlowSqlRepositoryBundle(connectionString, serviceId, schema));
config.Use(new FlowSqlRepositoryBundle(connectionString, tableName));
return config;
}
}
@ -18,21 +18,19 @@ namespace Tapeti.Flow.SQL
internal class FlowSqlRepositoryBundle : ITapetiExtension
{
private readonly string connectionString;
private readonly string schema;
private readonly int serviceId;
private readonly string tableName;
public FlowSqlRepositoryBundle(string connectionString, int serviceId, string schema)
public FlowSqlRepositoryBundle(string connectionString, string tableName)
{
this.connectionString = connectionString;
this.serviceId = serviceId;
this.schema = schema;
this.tableName = tableName;
}
public void RegisterDefaults(IDependencyContainer container)
{
container.RegisterDefault<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, serviceId, schema));
container.RegisterDefaultSingleton<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, tableName));
}

View File

@ -8,32 +8,28 @@ using Newtonsoft.Json;
namespace Tapeti.Flow.SQL
{
/*
Assumes the following table layout (schema configurable):
Assumes the following table layout (table name configurable and may include schema):
create table shared.Flow
create table Flow
(
FlowID uniqueidentifier not null,
ServiceID int not null,
CreationTime datetime2(3) not null,
StateJson nvarchar(max) null,
constraint PK_Flow primary key clustered (FlowID)
);
go;
*/
public class SqlConnectionFlowRepository : IFlowRepository
{
private readonly string connectionString;
private readonly int serviceId;
private readonly string schema;
private readonly string tableName;
public SqlConnectionFlowRepository(string connectionString, int serviceId, string schema)
public SqlConnectionFlowRepository(string connectionString, string tableName = "Flow")
{
this.connectionString = connectionString;
this.serviceId = serviceId;
this.schema = schema;
this.tableName = tableName;
}
@ -41,14 +37,7 @@ namespace Tapeti.Flow.SQL
{
using (var connection = await GetConnection())
{
var flowQuery = new SqlCommand($"select FlowID, StateJson from {schema}.Flow " +
"where ServiceID = @ServiceID ",
connection);
var flowServiceParam = flowQuery.Parameters.Add("@ServiceID", SqlDbType.Int);
flowServiceParam.Value = serviceId;
var flowQuery = new SqlCommand($"select FlowID, StateJson from {tableName}", connection);
var flowReader = await flowQuery.ExecuteReaderAsync();
var result = new List<KeyValuePair<Guid, T>>();
@ -67,21 +56,53 @@ namespace Tapeti.Flow.SQL
}
public Task CreateState<T>(Guid flowID, T state, DateTime timestamp)
public async Task CreateState<T>(Guid flowID, T state, DateTime timestamp)
{
//var stateJson = JsonConvert.SerializeObject(state);
using (var connection = await GetConnection())
{
var query = new SqlCommand($"insert into {tableName} (FlowID, StateJson, CreationTime)" +
"values (@FlowID, @StateJson, @CreationTime)",
connection);
throw new NotImplementedException();
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
var stateJsonParam = query.Parameters.Add("@StateJson", SqlDbType.NVarChar);
var creationTimeParam = query.Parameters.Add("@CreationTime", SqlDbType.DateTime2);
flowIDParam.Value = flowID;
stateJsonParam.Value = JsonConvert.SerializeObject(state);
creationTimeParam.Value = timestamp;
await query.ExecuteNonQueryAsync();
}
}
public Task UpdateState<T>(Guid flowID, T state)
public async Task UpdateState<T>(Guid flowID, T state)
{
throw new NotImplementedException();
using (var connection = await GetConnection())
{
var query = new SqlCommand($"update {tableName} set StateJson = @StateJson where FlowID = @FlowID", connection);
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
var stateJsonParam = query.Parameters.Add("@StateJson", SqlDbType.NVarChar);
flowIDParam.Value = flowID;
stateJsonParam.Value = JsonConvert.SerializeObject(state);
await query.ExecuteNonQueryAsync();
}
}
public Task DeleteState(Guid flowID)
public async Task DeleteState(Guid flowID)
{
throw new NotImplementedException();
using (var connection = await GetConnection())
{
var query = new SqlCommand($"delete from {tableName} where FlowID = @FlowID", connection);
var flowIDParam = query.Parameters.Add("@FlowID", SqlDbType.UniqueIdentifier);
flowIDParam.Value = flowID;
await query.ExecuteNonQueryAsync();
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti.Flow.SQL</id>
<id>Tapeti.Flow.SQL</id>
<version>$version$</version>
<title>Tapeti Flow SQL</title>
<authors>Mark van Renswoude</authors>
@ -14,8 +14,8 @@
<copyright></copyright>
<tags>rabbitmq tapeti sql</tags>
<dependencies>
<dependency id="X2Software.Tapeti" version="[$version$]" />
<dependency id="X2Software.Tapeti.Flow" version="[$version$]" />
<dependency id="Tapeti" version="[$version$]" />
<dependency id="Tapeti.Flow" version="[$version$]" />
<dependency id="System.Data.SqlClient" version="4.5.0" />
</dependencies>
</metadata>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti.Flow</id>
<id>Tapeti.Flow</id>
<version>$version$</version>
<title>Tapeti Flow</title>
<authors>Menno van Lavieren, Mark van Renswoude</authors>
@ -14,8 +14,8 @@
<copyright></copyright>
<tags>rabbitmq tapeti flow</tags>
<dependencies>
<dependency id="X2Software.Tapeti" version="[$version$]" />
<dependency id="X2Software.Tapeti.Annotations" version="[$version$]" />
<dependency id="Tapeti" version="[$version$]" />
<dependency id="Tapeti.Annotations" version="[$version$]" />
</dependencies>
</metadata>
<files>

View File

@ -1,20 +1,20 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti.Serilog</id>
<id>Tapeti.Serilog</id>
<version>$version$</version>
<title>Tapeti Serilog</title>
<authors>Hans Mulder</authors>
<owners>Hans Mulder</owners>
<licenseUrl>https://raw.githubusercontent.com/MvRens/Tapeti/master/UNLICENSE</licenseUrl>
<projectUrl>https://github.com/MvRens/Tapeti</projectUrl>
<iconUrl>https://raw.githubusercontent.com/MvRens/Tapeti/master/resources/icons/Tapeti.SimpleInjector.png</iconUrl>
<iconUrl>https://raw.githubusercontent.com/MvRens/Tapeti/master/resources/icons/Tapeti.Serilog.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>DEPRECATED: use Tapeti.Serilog</description>
<copyright></copyright>
<tags>rabbitmq tapeti simpleinjector serilog</tags>
<tags>rabbitmq tapeti serilog</tags>
<dependencies>
<dependency id="X2Software.Tapeti" version="[$version$]" />
<dependency id="Tapeti" version="[$version$]" />
<dependency id="Serilog" version="2.7.1" />
</dependencies>
</metadata>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti.SimpleInjector</id>
<id>Tapeti.SimpleInjector</id>
<version>$version$</version>
<title>Tapeti SimpleInjector</title>
<authors>Mark van Renswoude</authors>
@ -14,7 +14,7 @@
<copyright></copyright>
<tags>rabbitmq tapeti simpleinjector</tags>
<dependencies>
<dependency id="X2Software.Tapeti" version="[$version$]" />
<dependency id="Tapeti" version="[$version$]" />
<dependency id="SimpleInjector" version="4.3.0" />
</dependencies>
</metadata>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>X2Software.Tapeti</id>
<id>Tapeti</id>
<version>$version$</version>
<title>Tapeti</title>
<authors>Mark van Renswoude</authors>
@ -14,7 +14,7 @@
<copyright></copyright>
<tags>rabbitmq tapeti</tags>
<dependencies>
<dependency id="X2Software.Tapeti.Annotations" version="[$version$]" />
<dependency id="Tapeti.Annotations" version="[$version$]" />
<dependency id="Newtonsoft.Json" version="11.0.2"/>
<dependency id="RabbitMQ.Client" version="5.0.1"/>
<dependency id="System.Configuration.ConfigurationManager" version="4.5.0"/>

View File

@ -5,6 +5,7 @@ using Tapeti.DataAnnotations;
using Tapeti.Flow;
using Tapeti.SimpleInjector;
using System.Threading;
using Tapeti.Flow.SQL;
namespace Test
{
@ -12,10 +13,7 @@ namespace Test
{
private static void Main()
{
// TODO SQL based flow store
// TODO logging
// TODO uitzoeken of we consumers kunnen pauzeren (denk: SQL down) --> nee, EFDBContext Get Async maken en retryen? kan dat, of timeout dan Rabbit?
var container = new Container();
container.Register<MarcoEmitter>();
@ -23,6 +21,7 @@ namespace Test
container.Register<ILogger, Tapeti.Default.ConsoleLogger>();
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
//.WithFlowSqlRepository("Server=localhost;Database=TapetiTest;Integrated Security=true")
.WithFlow()
.WithDataAnnotations()
.RegisterAllControllers()

View File

@ -11,17 +11,19 @@ before_build:
after_build:
- cmd: ECHO nuget pack Tapeti\Tapeti.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: nuget pack Tapeti\Tapeti.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "X2Software.Tapeti.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "Tapeti.%GitVersion_NuGetVersion%.nupkg"
- cmd: nuget pack Tapeti.Annotations\Tapeti.Annotations.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "X2Software.Tapeti.Annotations.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "Tapeti.Annotations.%GitVersion_NuGetVersion%.nupkg"
- cmd: nuget pack Tapeti.DataAnnotations\Tapeti.DataAnnotations.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "X2Software.Tapeti.DataAnnotations.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "Tapeti.DataAnnotations.%GitVersion_NuGetVersion%.nupkg"
- cmd: nuget pack Tapeti.Flow\Tapeti.Flow.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "X2Software.Tapeti.Flow.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "Tapeti.Flow.%GitVersion_NuGetVersion%.nupkg"
- cmd: nuget pack Tapeti.Flow.SQL\Tapeti.Flow.SQL.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "Tapeti.Flow.SQL.%GitVersion_NuGetVersion%.nupkg"
- cmd: nuget pack Tapeti.SimpleInjector\Tapeti.SimpleInjector.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "X2Software.Tapeti.SimpleInjector.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "Tapeti.SimpleInjector.%GitVersion_NuGetVersion%.nupkg"
- cmd: nuget pack Tapeti.Serilog\Tapeti.Serilog.nuspec -version "%GitVersion_NuGetVersion%" -prop "target=%CONFIGURATION%"
- cmd: appveyor PushArtifact "X2Software.Tapeti.Serilog.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "Tapeti.Serilog.%GitVersion_NuGetVersion%.nupkg"
assembly_info:
patch: false

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB