Sfoglia il codice sorgente

Merge branch 'develop' of github.com:dotnetcore/CAP into develop

master
Savorboard 5 anni fa
parent
commit
bbc824adeb
12 ha cambiato i file con 84 aggiunte e 47 eliminazioni
  1. +1
    -0
      CAP.sln
  2. +25
    -14
      Directory.Build.props
  3. +8
    -5
      README.md
  4. +1
    -1
      src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj
  5. +1
    -1
      src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj
  6. +1
    -1
      src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj
  7. +13
    -6
      src/DotNetCore.CAP/Infrastructure/SnowflakeId.cs
  8. +6
    -3
      test/DotNetCore.CAP.MongoDB.Test/DotNetCore.CAP.MongoDB.Test.csproj
  9. +7
    -4
      test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj
  10. +7
    -4
      test/DotNetCore.CAP.PostgreSql.Test/DotNetCore.CAP.PostgreSql.Test.csproj
  11. +7
    -4
      test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj
  12. +7
    -4
      test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj

+ 1
- 0
CAP.sln Vedi File

@@ -31,6 +31,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{10C0818D
build.cake = build.cake
build.ps1 = build.ps1
build.sh = build.sh
Directory.Build.props = Directory.Build.props
build\index.cake = build\index.cake
build\util.cake = build\util.cake
build\version.cake = build\version.cake


+ 25
- 14
Directory.Build.props Vedi File

@@ -1,18 +1,29 @@
<Project>

<Import Project="build\version.props" />
<PropertyGroup Label="Package">
<Product>CAP</Product>
<Authors>.NET Core Community;Savorboard</Authors>
<RepositoryUrl>https://github.com/dotnetcore/CAP</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
<PackageIconUrl>https://avatars2.githubusercontent.com/u/19404084</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/CAP</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/CAP/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageTags>CAP;EventBus;Distributed Transaction</PackageTags>
<Description>EventBus and eventually consistency in distributed architectures.</Description>
</PropertyGroup>
<Import Project="build\version.props" />

<PropertyGroup Label="Package">
<Product>CAP</Product>
<Authors>.NET Core Community;Savorboard</Authors>
<RepositoryUrl>https://github.com/dotnetcore/CAP</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
<PackageIconUrl>https://avatars2.githubusercontent.com/u/19404084</PackageIconUrl>
<PackageProjectUrl>https://github.com/dotnetcore/CAP</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dotnetcore/CAP/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageTags>CAP;EventBus;Distributed Transaction</PackageTags>
<Description>EventBus outbox integration and eventually consistency in microservice architectures.</Description>
</PropertyGroup>

<!-- Using SourceLink -->
<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
</ItemGroup>

</Project>

+ 8
- 5
README.md Vedi File

@@ -104,7 +104,7 @@ public class PublishController : Controller
{
using (var transaction = connection.BeginTransaction(_capBus, autoCommit: true))
{
//your business code
//your business logic code

_capBus.Publish("xxx.services.show.time", DateTime.Now);
}
@@ -118,7 +118,7 @@ public class PublishController : Controller
{
using (var trans = dbContext.Database.BeginTransaction(_capBus, autoCommit: true))
{
//your business code
//your business logic code

_capBus.Publish("xxx.services.show.time", DateTime.Now);
}
@@ -131,7 +131,7 @@ public class PublishController : Controller

### Subscribe

**In Action Method**
**In Controller Action**

Add the Attribute `[CapSubscribe()]` on Action to subscribe message:

@@ -147,7 +147,7 @@ public class PublishController : Controller

```

**In Service Method**
**In Business Logic Service**

If your subscribe method is not in the Controller,then your subscribe class need to Inheritance `ICapSubscribe`:

@@ -179,7 +179,10 @@ public void ConfigureServices(IServiceCollection services)
//Note: The injection of services needs before of `services.AddCap()`
services.AddTransient<ISubscriberService,SubscriberService>();

services.AddCap(x=>{});
services.AddCap(x=>
{
//...
});
}
```



+ 1
- 1
src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj Vedi File

@@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="0.11.5" />
<PackageReference Include="Confluent.Kafka" Version="0.11.6" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
src/DotNetCore.CAP.MySql/DotNetCore.CAP.MySql.csproj Vedi File

@@ -15,7 +15,7 @@
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.0" />
<PackageReference Include="MySqlConnector" Version="0.43.0" />
<PackageReference Include="MySqlConnector" Version="0.46.1" />
</ItemGroup>

<ItemGroup>


+ 1
- 1
src/DotNetCore.CAP.PostgreSql/DotNetCore.CAP.PostgreSql.csproj Vedi File

@@ -15,7 +15,7 @@
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.1.0" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="Npgsql" Version="4.0.3" />
</ItemGroup>

<ItemGroup>


+ 13
- 6
src/DotNetCore.CAP/Infrastructure/SnowflakeId.cs Vedi File

@@ -2,7 +2,6 @@
// An object that generates IDs. This is broken into a separate class in case we ever want to support multiple worker threads per process

using System;
using System.Threading;

namespace DotNetCore.CAP.Infrastructure
{
@@ -24,10 +23,10 @@ namespace DotNetCore.CAP.Infrastructure
private static SnowflakeId _snowflakeId;

private readonly object _lock = new object();
private static readonly object s_lock = new object();
private static readonly object SLock = new object();
private long _lastTimestamp = -1L;

private SnowflakeId(long workerId, long datacenterId, long sequence = 0L)
public SnowflakeId(long workerId, long datacenterId, long sequence = 0L)
{
WorkerId = workerId;
DatacenterId = datacenterId;
@@ -46,11 +45,19 @@ namespace DotNetCore.CAP.Infrastructure

public long Sequence { get; internal set; }

public static SnowflakeId Default(long datacenterId = 0)
public static SnowflakeId Default()
{
lock (s_lock)
lock (SLock)
{
return _snowflakeId ?? (_snowflakeId = new SnowflakeId(Thread.CurrentThread.ManagedThreadId, datacenterId));
if (_snowflakeId != null)
{
return _snowflakeId;
}

var random = new Random();
var workerId = random.Next((int)MaxWorkerId);
var datacenterId = random.Next((int)MaxDatacenterId);
return _snowflakeId = new SnowflakeId(workerId, datacenterId);
}
}



+ 6
- 3
test/DotNetCore.CAP.MongoDB.Test/DotNetCore.CAP.MongoDB.Test.csproj Vedi File

@@ -10,9 +10,12 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="FluentAssertions" Version="5.4.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>


+ 7
- 4
test/DotNetCore.CAP.MySql.Test/DotNetCore.CAP.MySql.Test.csproj Vedi File

@@ -12,12 +12,15 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0" />


+ 7
- 4
test/DotNetCore.CAP.PostgreSql.Test/DotNetCore.CAP.PostgreSql.Test.csproj Vedi File

@@ -7,10 +7,13 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Npgsql" Version="4.0.3" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>


+ 7
- 4
test/DotNetCore.CAP.SqlServer.Test/DotNetCore.CAP.SqlServer.Test.csproj Vedi File

@@ -12,13 +12,16 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.0" />


+ 7
- 4
test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj Vedi File

@@ -6,13 +6,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
</ItemGroup>



Caricamento…
Annulla
Salva