diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 22aaa4d..0fb5a3c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,7 +18,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 6.0.x
+ dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
@@ -27,7 +27,7 @@ jobs:
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal --logger:trx
- name: Upload Test Results
- uses: actions/upload-artifact@v2.2.0
+ uses: actions/upload-artifact@v4
with:
# Artifact name
name: Test Results
diff --git a/.github/workflows/prerelease-nuget.yml b/.github/workflows/prerelease-nuget.yml
index 478713d..4fd114e 100644
--- a/.github/workflows/prerelease-nuget.yml
+++ b/.github/workflows/prerelease-nuget.yml
@@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 6.0.x
+ dotnet-version: 8.0.x
- uses: dotnet/nbgv@master
with:
diff --git a/.github/workflows/release-nuget.yml b/.github/workflows/release-nuget.yml
index ebba539..197394a 100644
--- a/.github/workflows/release-nuget.yml
+++ b/.github/workflows/release-nuget.yml
@@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
- dotnet-version: 6.0.x
+ dotnet-version: 8.0.x
- uses: dotnet/nbgv@master
with:
diff --git a/Directory.Build.props b/Directory.Build.props
index 436401f..cc7fa93 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,6 +1,6 @@
- net6.0
+ net8.0
latest
$(PackageVersion)
$(Version)
@@ -38,7 +38,7 @@
-
+
diff --git a/Packages.props b/Packages.props
index 765acc2..769d378 100644
--- a/Packages.props
+++ b/Packages.props
@@ -2,56 +2,58 @@
-
-
-
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
@@ -64,4 +66,4 @@
-
\ No newline at end of file
+
diff --git a/Vertex.sln b/Vertex.sln
index 1a59d2e..134fe0f 100644
--- a/Vertex.sln
+++ b/Vertex.sln
@@ -58,6 +58,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{69B221ED-2A00-494F-AC36-C08025BBD2E6}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
+ Packages.props = Packages.props
EndProjectSection
EndProject
Global
diff --git a/examples/Packages.props b/examples/Packages.props
index a63e0dd..5326166 100644
--- a/examples/Packages.props
+++ b/examples/Packages.props
@@ -2,10 +2,10 @@
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/Transfer.Client/Program.cs b/examples/Transfer.Client/Program.cs
index eb65ad4..bb1816d 100644
--- a/examples/Transfer.Client/Program.cs
+++ b/examples/Transfer.Client/Program.cs
@@ -4,8 +4,12 @@
using System.Linq;
using System.Threading.Tasks;
using IdGen;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Orleans;
+using Orleans.Configuration;
+using Orleans.Hosting;
using Transfer.IGrains.Common;
using Transfer.IGrains.DTx;
@@ -14,10 +18,11 @@ namespace Transfer.Client
internal class Program
{
private static readonly IdGenerator IdGen = new IdGenerator(0);
+ private static IHost host;
private static async Task Main(string[] args)
{
- using var client = await StartClientWithRetries();
+ var client = await StartClientWithRetries();
while (true)
{
@@ -31,7 +36,13 @@ private static async Task Main(string[] args)
{
await DTx(client);
}
+ else
+ {
+ break;
+ }
}
+
+ host.Dispose();
}
private static async Task Normal(IClusterClient client)
@@ -46,23 +57,28 @@ private static async Task Normal(IClusterClient client)
var topupTaskList = new List();
foreach (var account in Enumerable.Range(0, accountCount))
{
- topupTaskList.AddRange(Enumerable.Range(0, times).Select(x => client.GetGrain(account).TopUp(100, IdGen.CreateId().ToString())));
+ topupTaskList.AddRange(Enumerable.Range(0, times).Select(x =>
+ client.GetGrain(account).TopUp(100, IdGen.CreateId().ToString())));
}
topupWatch.Start();
await Task.WhenAll(topupTaskList);
topupWatch.Stop();
- Console.WriteLine($"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
+ Console.WriteLine(
+ $"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
foreach (var account in Enumerable.Range(0, accountCount))
{
- Console.WriteLine($"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
+ Console.WriteLine(
+ $"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
}
var transferWatch = new Stopwatch();
var transferTaskList = new List();
foreach (var account in Enumerable.Range(0, accountCount))
{
- transferTaskList.AddRange(Enumerable.Range(0, times).Select(x => client.GetGrain(account).Transfer(account + accountCount, 50, IdGen.CreateId().ToString())));
+ transferTaskList.AddRange(Enumerable.Range(0, times).Select(x =>
+ client.GetGrain(account)
+ .Transfer(account + accountCount, 50, IdGen.CreateId().ToString())));
}
transferWatch.Start();
@@ -72,12 +88,14 @@ private static async Task Normal(IClusterClient client)
$"{times * accountCount}The transfer is completed, taking: {transferWatch.ElapsedMilliseconds}ms");
foreach (var account in Enumerable.Range(0, accountCount))
{
- Console.WriteLine($"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
+ Console.WriteLine(
+ $"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
}
foreach (var account in Enumerable.Range(0, accountCount))
{
- Console.WriteLine($"The balance of account {account} is{await client.GetGrain(account + accountCount).GetBalance()}");
+ Console.WriteLine(
+ $"The balance of account {account} is{await client.GetGrain(account + accountCount).GetBalance()}");
}
}
catch (Exception e)
@@ -98,16 +116,19 @@ private static async Task DTx(IClusterClient client)
var topupTaskList = new List();
foreach (var account in Enumerable.Range(0, accountCount))
{
- topupTaskList.AddRange(Enumerable.Range(0, times).Select(x => client.GetGrain(account).TopUp(100, IdGen.CreateId().ToString())));
+ topupTaskList.AddRange(Enumerable.Range(0, times).Select(x =>
+ client.GetGrain(account).TopUp(100, IdGen.CreateId().ToString())));
}
topupWatch.Start();
await Task.WhenAll(topupTaskList);
topupWatch.Stop();
- Console.WriteLine($"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
+ Console.WriteLine(
+ $"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
foreach (var account in Enumerable.Range(0, accountCount))
{
- Console.WriteLine($"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
+ Console.WriteLine(
+ $"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
}
var transferWatch = new Stopwatch();
@@ -132,12 +153,14 @@ private static async Task DTx(IClusterClient client)
$"{times * accountCount}The transfer is completed, taking: {transferWatch.ElapsedMilliseconds}ms");
foreach (var account in Enumerable.Range(0, accountCount))
{
- Console.WriteLine($"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
+ Console.WriteLine(
+ $"The balance of account {account} is{await client.GetGrain(account).GetBalance()}");
}
foreach (var account in Enumerable.Range(0, accountCount))
{
- Console.WriteLine($"The balance of account {account} is{await client.GetGrain(account + accountCount).GetBalance()}");
+ Console.WriteLine(
+ $"The balance of account {account} is{await client.GetGrain(account + accountCount).GetBalance()}");
}
}
catch (Exception e)
@@ -154,13 +177,20 @@ private static async Task StartClientWithRetries(int initializeA
{
try
{
- var builder = new ClientBuilder()
- .UseLocalhostClustering()
- .ConfigureApplicationParts(parts =>
- parts.AddApplicationPart(typeof(IAccount).Assembly).WithReferences())
+ var builder = new HostBuilder()
+ .UseOrleansClient(clientBuilder =>
+ {
+ clientBuilder.UseLocalhostClustering();
+ clientBuilder.Configure(options =>
+ {
+ options.ClusterId = "dev";
+ options.ServiceId = "Transfer";
+ });
+ })
.ConfigureLogging(logging => logging.AddConsole());
- client = builder.Build();
- await client.Connect();
+ host = builder.Build();
+ await host.StartAsync();
+ client = host.Services.GetService();
Console.WriteLine("Client successfully connect to silo host");
break;
}
@@ -181,4 +211,4 @@ private static async Task StartClientWithRetries(int initializeA
return client;
}
}
-}
+}
\ No newline at end of file
diff --git a/examples/Transfer.Client/Transfer.Client.csproj b/examples/Transfer.Client/Transfer.Client.csproj
index 53c0fda..36cbd91 100644
--- a/examples/Transfer.Client/Transfer.Client.csproj
+++ b/examples/Transfer.Client/Transfer.Client.csproj
@@ -1,17 +1,18 @@
-
+
- Exe
- false
+ false
+ Exe
-
-
-
-
+
+
+
+
+
diff --git a/examples/Transfer.Grains/Snapshot/AccountSnapshot.cs b/examples/Transfer.Grains/Snapshot/AccountSnapshot.cs
index b085921..e24a212 100644
--- a/examples/Transfer.Grains/Snapshot/AccountSnapshot.cs
+++ b/examples/Transfer.Grains/Snapshot/AccountSnapshot.cs
@@ -1,12 +1,26 @@
-using Vertex.Abstractions.Serialization;
+using Orleans;
+using Vertex.Abstractions.Serialization;
using Vertex.Transaction.Abstractions.Snapshot;
namespace Transfer.Grains.Snapshot
{
+ ///
+ /// 账户快照类
+ ///
+ [GenerateSerializer]
public class AccountSnapshot : ITxSnapshot
{
+ ///
+ /// 账户余额
+ ///
+ [Id(0)]
public decimal Balance { get; set; }
+ ///
+ /// 克隆当前快照
+ ///
+ /// 序列化器
+ /// 克隆的账户快照
public AccountSnapshot Clone(ISerializer serializer)
{
return new AccountSnapshot
@@ -15,4 +29,4 @@ public AccountSnapshot Clone(ISerializer serializer)
};
}
}
-}
+}
\ No newline at end of file
diff --git a/examples/Transfer.Grains/Transfer.Grains.csproj b/examples/Transfer.Grains/Transfer.Grains.csproj
index be9c025..0e4d55e 100644
--- a/examples/Transfer.Grains/Transfer.Grains.csproj
+++ b/examples/Transfer.Grains/Transfer.Grains.csproj
@@ -1,10 +1,10 @@
-
+
false
-
+
diff --git a/examples/Transfer.IGrains/DTx/TransferRequest.cs b/examples/Transfer.IGrains/DTx/TransferRequest.cs
index 4a51293..1939000 100644
--- a/examples/Transfer.IGrains/DTx/TransferRequest.cs
+++ b/examples/Transfer.IGrains/DTx/TransferRequest.cs
@@ -1,13 +1,20 @@
-namespace Transfer.IGrains.DTx
+using Orleans;
+
+namespace Transfer.IGrains.DTx
{
+ [GenerateSerializer]
public class TransferRequest
{
+ [Id(0)]
public string Id { get; set; }
+ [Id(1)]
public long FromId { get; set; }
+ [Id(2)]
public long ToId { get; set; }
+ [Id(3)]
public decimal Amount { get; set; }
}
}
diff --git a/examples/Transfer.IGrains/Transfer.IGrains.csproj b/examples/Transfer.IGrains/Transfer.IGrains.csproj
index 2e7a11b..dfc3c7e 100644
--- a/examples/Transfer.IGrains/Transfer.IGrains.csproj
+++ b/examples/Transfer.IGrains/Transfer.IGrains.csproj
@@ -1,13 +1,19 @@
-
-
- false
-
-
-
-
-
-
+
+
+ net8.0
+ false
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/Transfer.Server/Program.cs b/examples/Transfer.Server/Program.cs
index 17351f2..3214d06 100644
--- a/examples/Transfer.Server/Program.cs
+++ b/examples/Transfer.Server/Program.cs
@@ -47,13 +47,13 @@ private static IHost CreateHost()
options.ServiceId = "Transfer";
})
.Configure(options => options.AdvertisedIPAddress = IPAddress.Loopback)
- .ConfigureApplicationParts(parts =>
- {
- parts.AddApplicationPart(typeof(Account).Assembly).WithReferences();
- parts.AddApplicationPart(typeof(DIDActor).Assembly).WithReferences();
- parts.AddApplicationPart(typeof(StreamIdActor).Assembly).WithReferences();
- })
- .AddSimpleMessageStreamProvider("SMSProvider", options => options.FireAndForgetDelivery = true).AddMemoryGrainStorage("PubSubStore");
+ // .ConfigureApplicationParts(parts =>
+ // {
+ // parts.AddApplicationPart(typeof(Account).Assembly).WithReferences();
+ // parts.AddApplicationPart(typeof(DIDActor).Assembly).WithReferences();
+ // parts.AddApplicationPart(typeof(StreamIdActor).Assembly).WithReferences();
+ // })
+ .AddMemoryStreams("SMSProvider").AddMemoryGrainStorage("PubSubStore");
})
.ConfigureServices(serviceCollection =>
{
diff --git a/examples/Transfer.Server/Transfer.Server.csproj b/examples/Transfer.Server/Transfer.Server.csproj
index 4fa3f71..bc7bf51 100644
--- a/examples/Transfer.Server/Transfer.Server.csproj
+++ b/examples/Transfer.Server/Transfer.Server.csproj
@@ -8,11 +8,11 @@
-
-
+
+
diff --git a/global.json b/global.json
index f96208c..b220006 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "6.0",
+ "version": "8.0",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
diff --git a/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerManager.cs b/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerManager.cs
index 3bf68dd..0897b7e 100644
--- a/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerManager.cs
+++ b/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerManager.cs
@@ -4,11 +4,11 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Orleans;
-using Orleans.Runtime;
using Orleans.Streams;
using Vertex.Abstractions.Actor;
using Vertex.Abstractions.InnerService;
@@ -124,7 +124,7 @@ private async Task DistributedStart()
{
try
{
- var streamProvider = this.provider.GetRequiredServiceByName(this.streamOptions.ProviderName);
+ var streamProvider = this.provider.GetRequiredKeyedService(this.streamOptions.ProviderName);
if (Interlocked.CompareExchange(ref this.distributedMonitorTimeLock, 1, 0) == 0)
{
foreach (var queue in this.queues)
diff --git a/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerRunner.cs b/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerRunner.cs
index 2085924..8dec4a4 100644
--- a/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerRunner.cs
+++ b/src/Stream/Vertex.Stream.InMemory/Consumer/ConsumerRunner.cs
@@ -47,7 +47,7 @@ public async Task Run()
await this.streamSubscriptionHandle.UnsubscribeAsync();
}
this.streamId = await this.grainFactory.GetGrain(0).GetId(this.Queue.Topic);
- var stream = this.streamProvider.GetStream(this.streamId, this.Queue.Name);
+ var stream = this.streamProvider.GetStream(this.Queue.Name, this.streamId);
this.streamSubscriptionHandle = await stream.SubscribeAsync(async bytesList => await this.Notice(bytesList.Select(o => new BytesBox(o.Item, default)).ToList()));
}
diff --git a/src/Stream/Vertex.Stream.InMemory/EventStreamFactory.cs b/src/Stream/Vertex.Stream.InMemory/EventStreamFactory.cs
index 9647640..935a9de 100644
--- a/src/Stream/Vertex.Stream.InMemory/EventStreamFactory.cs
+++ b/src/Stream/Vertex.Stream.InMemory/EventStreamFactory.cs
@@ -2,6 +2,7 @@
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Orleans;
using Orleans.Runtime;
@@ -62,9 +63,9 @@ public async ValueTask Create(IActor act
var streamId = await this.grainFactory.GetGrain(0).GetId(stream);
var result = this.streamDict.GetOrAdd(stream, key =>
{
- var streamProvider = this.serviceProvider.GetRequiredServiceByName(this.streamOptions.ProviderName);
+ var streamProvider = this.serviceProvider.GetRequiredKeyedService(this.streamOptions.ProviderName);
- return new EventStream(streamProvider.GetStream(streamId, attribute.Name));
+ return new EventStream(streamProvider.GetStream(attribute.Name, streamId));
});
return result;
}
diff --git a/src/Stream/Vertex.Stream.InMemory/Vertex.Stream.InMemory.csproj b/src/Stream/Vertex.Stream.InMemory/Vertex.Stream.InMemory.csproj
index dbf109e..198f5fb 100644
--- a/src/Stream/Vertex.Stream.InMemory/Vertex.Stream.InMemory.csproj
+++ b/src/Stream/Vertex.Stream.InMemory/Vertex.Stream.InMemory.csproj
@@ -3,8 +3,8 @@
-
-
+
+
diff --git a/src/Vertex.Abstractions/Event/EventDocument.cs b/src/Vertex.Abstractions/Event/EventDocument.cs
index 78d33d8..3cc3b03 100644
--- a/src/Vertex.Abstractions/Event/EventDocument.cs
+++ b/src/Vertex.Abstractions/Event/EventDocument.cs
@@ -1,17 +1,26 @@
-namespace Vertex.Abstractions.Event
+using Orleans;
+
+namespace Vertex.Abstractions.Event
{
+ [GenerateSerializer]
public class EventDocument
{
+ [Id(0)]
public string FlowId { get; set; }
+ [Id(1)]
public TPrimaryKey ActorId { get; set; }
+ [Id(2)]
public string Name { get; set; }
+ [Id(3)]
public string Data { get; set; }
+ [Id(4)]
public long Timestamp { get; set; }
+ [Id(5)]
public long Version { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Vertex.Abstractions/Event/EventDocumentDto.cs b/src/Vertex.Abstractions/Event/EventDocumentDto.cs
index ee2b12c..d3b57fa 100644
--- a/src/Vertex.Abstractions/Event/EventDocumentDto.cs
+++ b/src/Vertex.Abstractions/Event/EventDocumentDto.cs
@@ -1,15 +1,23 @@
-namespace Vertex.Abstractions.Event
+using Orleans;
+
+namespace Vertex.Abstractions.Event
{
+ [GenerateSerializer]
public class EventDocumentDto
{
+ [Id(0)]
public string Name { get; set; }
+ [Id(1)]
public string Data { get; set; }
+ [Id(2)]
public string FlowId { get; set; }
+ [Id(3)]
public long Timestamp { get; set; }
+ [Id(4)]
public long Version { get; set; }
}
}
diff --git a/src/Vertex.Abstractions/Event/EventMeta.cs b/src/Vertex.Abstractions/Event/EventMeta.cs
index 4d01129..8eb9f98 100644
--- a/src/Vertex.Abstractions/Event/EventMeta.cs
+++ b/src/Vertex.Abstractions/Event/EventMeta.cs
@@ -1,23 +1,29 @@
-using Orleans.Concurrency;
+using Orleans;
namespace Vertex.Abstractions.Event
{
///
- /// Record the meta information of the event
+ /// 记录事件的元信息
///
- [Immutable]
- public record EventMeta
+ [GenerateSerializer]
+ public class EventMeta
{
+ ///
+ /// 流程ID
+ ///
+ [Id(0)]
public string FlowId { get; set; }
///
- /// Used to describe the sequence of events produced by an actor
+ /// 用于描述由演员生成的事件序列
///
+ [Id(1)]
public long Version { get; init; }
///
- /// Records the timestamp generated by the event, accurate to seconds
+ /// 记录事件生成的时间戳,精确到秒
///
+ [Id(2)]
public long Timestamp { get; init; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Vertex.Abstractions/Event/EventUnit.cs b/src/Vertex.Abstractions/Event/EventUnit.cs
index 75af9d8..de82671 100644
--- a/src/Vertex.Abstractions/Event/EventUnit.cs
+++ b/src/Vertex.Abstractions/Event/EventUnit.cs
@@ -1,15 +1,21 @@
-namespace Vertex.Abstractions.Event
+using Orleans;
+
+namespace Vertex.Abstractions.Event
{
///
/// A typed wrapper for an event that contains details about the event.
///
/// The type of the entity's key.
+ [GenerateSerializer]
public class EventUnit
{
- public IEvent Event { get; set; }
+ [Id(0)]
+ public TPrimaryKey ActorId { get; set; }
+ [Id(1)]
public EventMeta Meta { get; set; }
- public TPrimaryKey ActorId { get; set; }
+ [Id(3)]
+ public IEvent Event { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Vertex.Abstractions/Snapshot/SnapshotMeta.cs b/src/Vertex.Abstractions/Snapshot/SnapshotMeta.cs
index 05671fb..9f47abf 100644
--- a/src/Vertex.Abstractions/Snapshot/SnapshotMeta.cs
+++ b/src/Vertex.Abstractions/Snapshot/SnapshotMeta.cs
@@ -1,17 +1,47 @@
-namespace Vertex.Abstractions.Snapshot
+using Orleans;
+
+namespace Vertex.Abstractions.Snapshot
{
+ ///
+ /// 快照元数据类
+ ///
+ [GenerateSerializer]
public record SnapshotMeta
{
+ ///
+ /// 演员ID
+ ///
+ [Id(0)]
public TPrimaryKey ActorId { get; set; }
+ ///
+ /// 正在处理的版本
+ ///
+ [Id(1)]
public long DoingVersion { get; set; }
+ ///
+ /// 版本
+ ///
+ [Id(2)]
public long Version { get; set; }
+ ///
+ /// 最小事件时间戳
+ ///
+ [Id(3)]
public long MinEventTimestamp { get; set; }
+ ///
+ /// 最小事件版本
+ ///
+ [Id(4)]
public long MinEventVersion { get; set; }
+ ///
+ /// 是否是最新的
+ ///
+ [Id(5)]
public bool IsLatest { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Vertex.Abstractions/Snapshot/SnapshotUnit.cs b/src/Vertex.Abstractions/Snapshot/SnapshotUnit.cs
index a4ebec4..302ee7a 100644
--- a/src/Vertex.Abstractions/Snapshot/SnapshotUnit.cs
+++ b/src/Vertex.Abstractions/Snapshot/SnapshotUnit.cs
@@ -1,10 +1,15 @@
-namespace Vertex.Abstractions.Snapshot
+using Orleans;
+
+namespace Vertex.Abstractions.Snapshot
{
+ [GenerateSerializer]
public record SnapshotUnit
where T : ISnapshot
{
+ [Id(0)]
public SnapshotMeta Meta { get; set; }
+ [Id(1)]
public T Data { get; set; }
}
}
diff --git a/src/Vertex.Abstractions/Snapshot/SubSnapshot.cs b/src/Vertex.Abstractions/Snapshot/SubSnapshot.cs
index 729cd4e..0fd4dbc 100644
--- a/src/Vertex.Abstractions/Snapshot/SubSnapshot.cs
+++ b/src/Vertex.Abstractions/Snapshot/SubSnapshot.cs
@@ -1,11 +1,26 @@
-namespace Vertex.Abstractions.Snapshot
+using Orleans;
+
+namespace Vertex.Abstractions.Snapshot
{
+ ///
+ /// 子快照类
+ ///
+ [GenerateSerializer]
public record SubSnapshot
{
+ [Id(0)]
public TPrimaryKey ActorId { get; set; }
+ ///
+ /// 正在处理的版本
+ ///
+ [Id(1)]
public long DoingVersion { get; set; }
+ ///
+ /// 版本
+ ///
+ [Id(2)]
public long Version { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Vertex.Abstractions/Vertex.Abstractions.csproj b/src/Vertex.Abstractions/Vertex.Abstractions.csproj
index ac25800..7789df7 100644
--- a/src/Vertex.Abstractions/Vertex.Abstractions.csproj
+++ b/src/Vertex.Abstractions/Vertex.Abstractions.csproj
@@ -1,8 +1,8 @@
-
+
diff --git a/src/Vertex.Runtime/Actor/ActorBase.cs b/src/Vertex.Runtime/Actor/ActorBase.cs
index 46d516f..1df717b 100644
--- a/src/Vertex.Runtime/Actor/ActorBase.cs
+++ b/src/Vertex.Runtime/Actor/ActorBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading;
using System.Threading.Tasks;
using Orleans;
using Vertex.Abstractions.Actor;
@@ -23,7 +24,12 @@ public ActorBase()
///
protected Type ActorType { get; }
- public override Task OnActivateAsync()
+ public Task OnActivateAsync()
+ {
+ return this.OnActivateAsync(CancellationToken.None);
+ }
+
+ public override Task OnActivateAsync(CancellationToken cancellationToken)
{
var type = typeof(TPrimaryKey);
if (type == typeof(long) && this.GetPrimaryKeyLong() is TPrimaryKey longKey)
@@ -43,7 +49,7 @@ public override Task OnActivateAsync()
throw new ArgumentOutOfRangeException(typeof(TPrimaryKey).FullName);
}
- return base.OnActivateAsync();
+ return base.OnActivateAsync(cancellationToken);
}
}
}
diff --git a/src/Vertex.Runtime/Actor/FlowActor.cs b/src/Vertex.Runtime/Actor/FlowActor.cs
index b31114d..73ca2b2 100644
--- a/src/Vertex.Runtime/Actor/FlowActor.cs
+++ b/src/Vertex.Runtime/Actor/FlowActor.cs
@@ -7,11 +7,13 @@
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
+using Orleans;
using Orleans.Concurrency;
using Orleans.Runtime;
using Vertex.Abstractions.Actor;
@@ -365,9 +367,9 @@ protected virtual async ValueTask DependencyInjection()
this.SnapshotStorage = await snapshotStorageFactory.Create(this);
}
- public override async Task OnActivateAsync()
+ public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
- await base.OnActivateAsync();
+ await base.OnActivateAsync(cancellationToken);
await this.DependencyInjection();
if (this.ConcurrentHandle)
@@ -395,13 +397,14 @@ public override async Task OnActivateAsync()
}
}
- public override async Task OnDeactivateAsync()
+ public override async Task OnDeactivateAsync(DeactivationReason reason, CancellationToken cancellationToken)
{
await this.SaveSnapshotAsync(isDeactivate: true);
if (this.Logger.IsEnabled(LogLevel.Trace))
{
this.Logger.LogTrace("Deactivate completed: {0}->{1}", this.ActorType.Name, this.Serializer.Serialize(this.Snapshot));
+ this.Logger.LogTrace("Deactivate reason: {0}->{1}", this.ActorType.Name, reason.Description);
}
}
diff --git a/src/Vertex.Runtime/Actor/ShadowActor.cs b/src/Vertex.Runtime/Actor/ShadowActor.cs
index a2f3616..7366f25 100644
--- a/src/Vertex.Runtime/Actor/ShadowActor.cs
+++ b/src/Vertex.Runtime/Actor/ShadowActor.cs
@@ -3,6 +3,7 @@
using System.Data;
using System.Linq;
using System.Runtime.CompilerServices;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -65,9 +66,9 @@ protected virtual async ValueTask DependencyInjection()
this.SnapshotStorage = await snapshotStorageFactory.Create(this);
}
- public override async Task OnActivateAsync()
+ public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
- await base.OnActivateAsync();
+ await base.OnActivateAsync(cancellationToken);
await this.DependencyInjection();
try
diff --git a/src/Vertex.Runtime/Actor/VertexActor.cs b/src/Vertex.Runtime/Actor/VertexActor.cs
index e2307fc..106b196 100644
--- a/src/Vertex.Runtime/Actor/VertexActor.cs
+++ b/src/Vertex.Runtime/Actor/VertexActor.cs
@@ -5,10 +5,12 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
+using Orleans;
using Orleans.Runtime;
using Vertex.Abstractions.Actor;
using Vertex.Abstractions.Event;
@@ -103,9 +105,9 @@ protected virtual async ValueTask DependencyInjection()
/// The method used to initialize is called when Grain is activated (overriding in subclasses is prohibited)
///
/// A representing the asynchronous operation.
- public override async Task OnActivateAsync()
+ public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
- await base.OnActivateAsync();
+ await base.OnActivateAsync(cancellationToken);
await this.DependencyInjection();
// Load snapshot
@@ -250,7 +252,7 @@ protected virtual ValueTask CreateSnapshot()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected virtual ValueTask OnStartSaveSnapshot() => ValueTask.CompletedTask;
- public override async Task OnDeactivateAsync()
+ public override async Task OnDeactivateAsync(DeactivationReason reason, CancellationToken cancellationToken)
{
try
{
@@ -263,6 +265,7 @@ public override async Task OnDeactivateAsync()
if (this.Logger.IsEnabled(LogLevel.Trace))
{
this.Logger.LogTrace("Deactivate completed: {0}->{1}", this.ActorType.FullName, this.Serializer.Serialize(this.Snapshot));
+ this.Logger.LogTrace("Deactivate reason: {0}->{1}", this.ActorType.Name, reason.Description);
}
}
catch (Exception ex)
diff --git a/src/Vertex.Runtime/Options/ActorOptions.cs b/src/Vertex.Runtime/Options/ActorOptions.cs
index b7e473f..6593765 100644
--- a/src/Vertex.Runtime/Options/ActorOptions.cs
+++ b/src/Vertex.Runtime/Options/ActorOptions.cs
@@ -1,20 +1,26 @@
-namespace Vertex.Runtime.Options
+using Orleans;
+
+namespace Vertex.Runtime.Options
{
+ [GenerateSerializer]
public class ActorOptions
{
///
/// Event Version interval of RayGrain saving snapshot
///
+ [Id(0)]
public int SnapshotVersionInterval { get; set; } = 500;
///
/// The minimum event Version interval for saving snapshots when RayGrain is deactivated
///
+ [Id(1)]
public int MinSnapshotVersionInterval { get; set; } = 1;
///
/// The amount of data read each time when reading events in batches
///
+ [Id(2)]
public int EventPageSize { get; set; } = 2000;
}
}
diff --git a/src/Vertex.Runtime/Options/ArchiveOptions.cs b/src/Vertex.Runtime/Options/ArchiveOptions.cs
index 5f93e6f..24ef471 100644
--- a/src/Vertex.Runtime/Options/ArchiveOptions.cs
+++ b/src/Vertex.Runtime/Options/ArchiveOptions.cs
@@ -1,17 +1,23 @@
-namespace Vertex.Runtime.Options
+using Orleans;
+
+namespace Vertex.Runtime.Options
{
+ [GenerateSerializer]
public class ArchiveOptions
{
///
/// The minimum number of seconds between archiving (default 1 days)
///
+ [Id(0)]
public long MinIntervalSeconds { get; set; } = 24 * 60 * 60;
+ [Id(1)]
public int EventPageSize { get; set; } = 3000;
///
/// The maximum number of seconds between archiving, as long as the interval is greater than this value, you can archive (default 7 days)
///
+ [Id(2)]
public long RetainSeconds { get; set; } = 24 * 60 * 60 * 7;
}
}
diff --git a/src/Vertex.Runtime/Options/FlowActorOptions.cs b/src/Vertex.Runtime/Options/FlowActorOptions.cs
index 4432ade..cccdf5c 100644
--- a/src/Vertex.Runtime/Options/FlowActorOptions.cs
+++ b/src/Vertex.Runtime/Options/FlowActorOptions.cs
@@ -1,37 +1,47 @@
-namespace Vertex.Runtime.Options
+using Orleans;
+
+namespace Vertex.Runtime.Options
{
+ [GenerateSerializer]
public class FlowActorOptions
{
///
/// Event Version interval of FlowActor saving snapshot
///
+ [Id(0)]
public int SnapshotVersionInterval { get; set; } = 500;
///
/// The minimum event Version interval for saving snapshot when FlowActor is deactivated
///
+ [Id(1)]
public int MinSnapshotVersionInterval { get; set; } = 1;
///
/// The amount of data read each time when reading events in batches
///
+ [Id(2)]
public int EventPageSize { get; set; } = 1000;
+ [Id(3)]
public FlowInitType InitType { get; set; } = FlowInitType.FirstReceive;
///
/// Enable snapshot caching
///
+ [Id(4)]
public bool EnableSnapshotCache { get; set; }
///
/// Event Version interval of FlowActor snapshot cache
///
+ [Id(5)]
public int SnapshotCacheVersionInterval { get; set; }
///
/// The minimum event Version interval for saving snapshot cache when FlowActor is deactivated
///
+ [Id(6)]
public int MinSnapshotCacheVersionInterval { get; set; } = 1;
}
}
diff --git a/src/Vertex.Runtime/Options/ShadowActorOptions.cs b/src/Vertex.Runtime/Options/ShadowActorOptions.cs
index 7d9edbe..eaba4c4 100644
--- a/src/Vertex.Runtime/Options/ShadowActorOptions.cs
+++ b/src/Vertex.Runtime/Options/ShadowActorOptions.cs
@@ -1,10 +1,14 @@
-namespace Vertex.Runtime.Options
+using Orleans;
+
+namespace Vertex.Runtime.Options
{
+ [GenerateSerializer]
public class ShadowActorOptions
{
///
/// The amount of data read each time when reading events in batches
///
+ [Id(0)]
public int EventPageSize { get; set; } = 1000;
}
}
diff --git a/src/Vertex.Runtime/Vertex.Runtime.csproj b/src/Vertex.Runtime/Vertex.Runtime.csproj
index 9bd8e21..6ede958 100644
--- a/src/Vertex.Runtime/Vertex.Runtime.csproj
+++ b/src/Vertex.Runtime/Vertex.Runtime.csproj
@@ -4,8 +4,7 @@
-
-
+
diff --git a/src/Vertex.Transaction.Abstractions/Vertex.Transaction.Abstractions.csproj b/src/Vertex.Transaction.Abstractions/Vertex.Transaction.Abstractions.csproj
index 30e1a43..de48c13 100644
--- a/src/Vertex.Transaction.Abstractions/Vertex.Transaction.Abstractions.csproj
+++ b/src/Vertex.Transaction.Abstractions/Vertex.Transaction.Abstractions.csproj
@@ -1,7 +1,7 @@
-
+
diff --git a/src/Vertex.Transaction/Actor/DTxActor.cs b/src/Vertex.Transaction/Actor/DTxActor.cs
index ded6744..c0c52b7 100644
--- a/src/Vertex.Transaction/Actor/DTxActor.cs
+++ b/src/Vertex.Transaction/Actor/DTxActor.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -36,9 +37,9 @@ protected async override ValueTask DependencyInjection()
await base.DependencyInjection();
}
- public override async Task OnActivateAsync()
+ public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
- await base.OnActivateAsync();
+ await base.OnActivateAsync(cancellationToken);
var txEvents = this.Convert(await this.TxEventStorage.GetLatest(this.ActorId, this.DtxOptions.RetainedTxEvents));
if (txEvents.Count > 0)
{
@@ -53,7 +54,7 @@ public override async Task OnActivateAsync()
if (!string.IsNullOrEmpty(this.TxSnapshot.TxId))
{
- await this.TxBeginLock.WaitAsync();
+ await this.TxBeginLock.WaitAsync(cancellationToken);
var documents = await this.EventStorage.GetList(this.ActorId, this.TxSnapshot.TxStartVersion, this.Snapshot.Meta.Version);
var waitingEvents = this.Convert(documents);
foreach (var evt in waitingEvents)
diff --git a/src/Vertex.Transaction/Actor/DTxUnitActor.cs b/src/Vertex.Transaction/Actor/DTxUnitActor.cs
index 6f594ad..ba59092 100644
--- a/src/Vertex.Transaction/Actor/DTxUnitActor.cs
+++ b/src/Vertex.Transaction/Actor/DTxUnitActor.cs
@@ -26,10 +26,10 @@ public abstract class DTxUnitActor :
private readonly IdGenerator idGen = new IdGenerator(0);
private IDisposable timer;
- public override async Task OnActivateAsync()
+ public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
- await base.OnActivateAsync();
- this.timer = this.RegisterTimer(
+ await base.OnActivateAsync(cancellationToken);
+ this.timer = this.RegisterGrainTimer
+
+
+
diff --git a/test/Vertex.Runtime.Test/Biz/Actors/Account.cs b/test/Vertex.Runtime.Test/Biz/Actors/Account.cs
index 3238615..5b7c378 100644
--- a/test/Vertex.Runtime.Test/Biz/Actors/Account.cs
+++ b/test/Vertex.Runtime.Test/Biz/Actors/Account.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
+using Orleans;
using Vertex.Abstractions.Event;
using Vertex.Abstractions.Snapshot;
using Vertex.Runtime.Actor;
@@ -119,7 +121,7 @@ public async Task RecoverySnapshot_Test()
public async Task Deactivate_Test()
{
- await this.OnDeactivateAsync();
+ await this.OnDeactivateAsync(new DeactivationReason(DeactivationReasonCode.None, string.Empty), CancellationToken.None);
await this.CreateSnapshot();
}
diff --git a/test/Vertex.Runtime.Test/Biz/Events/ErrorTestEvent.cs b/test/Vertex.Runtime.Test/Biz/Events/ErrorTestEvent.cs
index a75c9dc..32a4dbe 100644
--- a/test/Vertex.Runtime.Test/Biz/Events/ErrorTestEvent.cs
+++ b/test/Vertex.Runtime.Test/Biz/Events/ErrorTestEvent.cs
@@ -1,8 +1,10 @@
-using Vertex.Abstractions.Event;
+using Orleans;
+using Vertex.Abstractions.Event;
namespace Vertex.Runtime.Test.Events
{
[EventName(nameof(ErrorTestEvent))]
+ [GenerateSerializer]
public class ErrorTestEvent : IEvent
{
}
diff --git a/test/Vertex.Runtime.Test/Biz/Events/TopupEvent.cs b/test/Vertex.Runtime.Test/Biz/Events/TopupEvent.cs
index 37bbdb6..81255e9 100644
--- a/test/Vertex.Runtime.Test/Biz/Events/TopupEvent.cs
+++ b/test/Vertex.Runtime.Test/Biz/Events/TopupEvent.cs
@@ -1,12 +1,16 @@
-using Vertex.Abstractions.Event;
+using Orleans;
+using Vertex.Abstractions.Event;
namespace Vertex.Runtime.Test.Events
{
[EventName(nameof(TopupEvent))]
+ [GenerateSerializer]
public class TopupEvent : IEvent
{
+ [Id(0)]
public decimal Amount { get; set; }
+ [Id(1)]
public decimal Balance { get; set; }
}
}
diff --git a/test/Vertex.Runtime.Test/Biz/Events/TransferArrivedEvent.cs b/test/Vertex.Runtime.Test/Biz/Events/TransferArrivedEvent.cs
index 8042bcb..1846af6 100644
--- a/test/Vertex.Runtime.Test/Biz/Events/TransferArrivedEvent.cs
+++ b/test/Vertex.Runtime.Test/Biz/Events/TransferArrivedEvent.cs
@@ -1,12 +1,16 @@
-using Vertex.Abstractions.Event;
+using Orleans;
+using Vertex.Abstractions.Event;
namespace Vertex.Runtime.Test.Events
{
[EventName(nameof(TransferArrivedEvent))]
+ [GenerateSerializer]
public class TransferArrivedEvent : IEvent
{
+ [Id(0)]
public decimal Amount { get; set; }
+ [Id(1)]
public decimal Balance { get; set; }
}
}
diff --git a/test/Vertex.Runtime.Test/Biz/Events/TransferEvent.cs b/test/Vertex.Runtime.Test/Biz/Events/TransferEvent.cs
index 82fb706..a8ec491 100644
--- a/test/Vertex.Runtime.Test/Biz/Events/TransferEvent.cs
+++ b/test/Vertex.Runtime.Test/Biz/Events/TransferEvent.cs
@@ -1,14 +1,19 @@
-using Vertex.Abstractions.Event;
+using Orleans;
+using Vertex.Abstractions.Event;
namespace Vertex.Runtime.Test.Events
{
[EventName(nameof(TransferEvent))]
+ [GenerateSerializer]
public class TransferEvent : IEvent
{
+ [Id(0)]
public long ToId { get; set; }
+ [Id(1)]
public decimal Amount { get; set; }
+ [Id(2)]
public decimal Balance { get; set; }
}
}
diff --git a/test/Vertex.Runtime.Test/Biz/Events/TransferRefundsEvent.cs b/test/Vertex.Runtime.Test/Biz/Events/TransferRefundsEvent.cs
index 7417f7e..cbafad3 100644
--- a/test/Vertex.Runtime.Test/Biz/Events/TransferRefundsEvent.cs
+++ b/test/Vertex.Runtime.Test/Biz/Events/TransferRefundsEvent.cs
@@ -1,12 +1,16 @@
-using Vertex.Abstractions.Event;
+using Orleans;
+using Vertex.Abstractions.Event;
namespace Vertex.Runtime.Test.Events
{
[EventName(nameof(TransferRefundsEvent))]
+ [GenerateSerializer]
public class TransferRefundsEvent : IEvent
{
+ [Id(0)]
public decimal Amount { get; set; }
+ [Id(1)]
public decimal Balance { get; set; }
}
}
diff --git a/test/Vertex.Runtime.Test/Biz/Snapshot/AccountSnapshot.cs b/test/Vertex.Runtime.Test/Biz/Snapshot/AccountSnapshot.cs
index bdf3c74..7ecf6d5 100644
--- a/test/Vertex.Runtime.Test/Biz/Snapshot/AccountSnapshot.cs
+++ b/test/Vertex.Runtime.Test/Biz/Snapshot/AccountSnapshot.cs
@@ -1,9 +1,18 @@
-using Vertex.Abstractions.Snapshot;
+using Orleans;
+using Vertex.Abstractions.Snapshot;
namespace Vertex.Runtime.Test.Snapshot
{
+ ///
+ /// 账户快照类
+ ///
+ [GenerateSerializer]
public class AccountSnapshot : ISnapshot
{
+ ///
+ /// 账户余额
+ ///
+ [Id(0)]
public decimal Balance { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/test/Vertex.Runtime.Test/Core/TestSiloConfigurations.cs b/test/Vertex.Runtime.Test/Core/TestSiloConfigurations.cs
index 983e98a..12411fc 100644
--- a/test/Vertex.Runtime.Test/Core/TestSiloConfigurations.cs
+++ b/test/Vertex.Runtime.Test/Core/TestSiloConfigurations.cs
@@ -34,7 +34,7 @@ public void Configure(ISiloBuilder hostBuilder)
}
};
}, new EventArchivePolicy("month", (name, time) => $"Vertex_Archive_{name}_{DateTimeOffset.FromUnixTimeSeconds(time):yyyyMM}".ToLower(), table => table.StartsWith("Vertex_Archive".ToLower())));
- }).AddSimpleMessageStreamProvider("SMSProvider", options => options.FireAndForgetDelivery = true).AddMemoryGrainStorage("PubSubStore");
+ }).AddMemoryStreams("SMSProvider").AddMemoryGrainStorage("PubSubStore");
}
}
}
diff --git a/test/Vertex.Runtime.Test/Serialization/NoNamedEvent.cs b/test/Vertex.Runtime.Test/Serialization/NoNamedEvent.cs
index c81d33a..d849d6f 100644
--- a/test/Vertex.Runtime.Test/Serialization/NoNamedEvent.cs
+++ b/test/Vertex.Runtime.Test/Serialization/NoNamedEvent.cs
@@ -1,7 +1,9 @@
-using Vertex.Abstractions.Event;
+using Orleans;
+using Vertex.Abstractions.Event;
namespace Vertex.Runtime.Test.Serialization
{
+ [GenerateSerializer]
public class NoNamedEvent : IEvent
{
}
diff --git a/test/Vertex.Runtime.Test/Vertex.Runtime.Test.csproj b/test/Vertex.Runtime.Test/Vertex.Runtime.Test.csproj
index 14bfb8f..0e60e5f 100644
--- a/test/Vertex.Runtime.Test/Vertex.Runtime.Test.csproj
+++ b/test/Vertex.Runtime.Test/Vertex.Runtime.Test.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/test/Vertex.TxRuntime.Test/Biz/Models/TransferRequest.cs b/test/Vertex.TxRuntime.Test/Biz/Models/TransferRequest.cs
index c8c1a42..91171a6 100644
--- a/test/Vertex.TxRuntime.Test/Biz/Models/TransferRequest.cs
+++ b/test/Vertex.TxRuntime.Test/Biz/Models/TransferRequest.cs
@@ -1,18 +1,26 @@
-namespace Vertex.TxRuntime.Test.Biz.Models
+using Orleans;
+
+namespace Vertex.TxRuntime.Test.Biz.Models
{
+ [GenerateSerializer]
public class TransferRequest
{
+ [Id(0)]
public string Id { get; set; }
+ [Id(1)]
public long FromId { get; set; }
+ [Id(2)]
public long ToId { get; set; }
+ [Id(3)]
public decimal Amount { get; set; }
///
/// only for test
///
+ [Id(4)]
public bool Success { get; set; }
}
}
diff --git a/test/Vertex.TxRuntime.Test/Biz/Snapshot/AccountSnapshot.cs b/test/Vertex.TxRuntime.Test/Biz/Snapshot/AccountSnapshot.cs
index 89f43dd..6c2b8e4 100644
--- a/test/Vertex.TxRuntime.Test/Biz/Snapshot/AccountSnapshot.cs
+++ b/test/Vertex.TxRuntime.Test/Biz/Snapshot/AccountSnapshot.cs
@@ -1,12 +1,26 @@
-using Vertex.Abstractions.Serialization;
+using Orleans;
+using Vertex.Abstractions.Serialization;
using Vertex.Transaction.Abstractions.Snapshot;
namespace Vertex.TxRuntime.Test.Snapshot
{
+ ///
+ /// 账户快照类
+ ///
+ [GenerateSerializer]
public class AccountSnapshot : ITxSnapshot
{
+ ///
+ /// 账户余额
+ ///
+ [Id(0)]
public decimal Balance { get; set; }
+ ///
+ /// 克隆当前快照
+ ///
+ /// 序列化器
+ /// 克隆的账户快照
public AccountSnapshot Clone(ISerializer serializer)
{
return new AccountSnapshot
@@ -15,4 +29,4 @@ public AccountSnapshot Clone(ISerializer serializer)
};
}
}
-}
+}
\ No newline at end of file
diff --git a/test/Vertex.TxRuntime.Test/Core/TestSiloConfigurations.cs b/test/Vertex.TxRuntime.Test/Core/TestSiloConfigurations.cs
index aac8e45..50b7e4d 100644
--- a/test/Vertex.TxRuntime.Test/Core/TestSiloConfigurations.cs
+++ b/test/Vertex.TxRuntime.Test/Core/TestSiloConfigurations.cs
@@ -38,7 +38,7 @@ public void Configure(ISiloBuilder hostBuilder)
}
};
}, new EventArchivePolicy("month", (name, time) => $"Vertex_Archive_{name}_{DateTimeOffset.FromUnixTimeSeconds(time):yyyyMM}".ToLower(), table => table.StartsWith("Vertex_Archive".ToLower())));
- }).AddSimpleMessageStreamProvider("SMSProvider", options => options.FireAndForgetDelivery = true).AddMemoryGrainStorage("PubSubStore");
+ }) .AddMemoryStreams("SMSProvider").AddMemoryGrainStorage("PubSubStore");
}
}
}
diff --git a/test/Vertex.TxRuntime.Test/Vertex.TxRuntime.Test.csproj b/test/Vertex.TxRuntime.Test/Vertex.TxRuntime.Test.csproj
index f5b5422..02823ef 100644
--- a/test/Vertex.TxRuntime.Test/Vertex.TxRuntime.Test.csproj
+++ b/test/Vertex.TxRuntime.Test/Vertex.TxRuntime.Test.csproj
@@ -7,7 +7,7 @@
-
+