Skip to content

Commit beac4d0

Browse files
committed
🎉 更新(dependencies): 更新Orleans相关依赖为最新版本并修复项目引用问题。
1 parent 6c7cd0c commit beac4d0

11 files changed

Lines changed: 61 additions & 36 deletions

File tree

Packages.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
<PackageReference Update="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" />
1414
<PackageReference Update="BenchmarkDotNet" Version="0.14.0" />
1515

16-
<PackageReference Update="Microsoft.Orleans.OrleansProviders" Version="8.2.0"/>
1716
<PackageReference Update="Microsoft.Orleans.Core" Version="8.2.0" />
1817
<PackageReference Update="Microsoft.Orleans.Sdk" Version="8.2.0" />
18+
<PackageReference Update="Microsoft.Orleans.CodeGenerator" Version="8.2.0" />
1919
<PackageReference Update="Microsoft.Orleans.Streaming" Version="8.2.0" />
2020
<PackageReference Update="Microsoft.Orleans.Core.Abstractions" Version="8.2.0" />
2121
<PackageReference Update="Microsoft.Orleans.Runtime.Abstractions" Version="8.2.0" />
2222
<PackageReference Update="Microsoft.Orleans.OrleansRuntime" Version="8.2.0" />
2323
<PackageReference Update="Microsoft.Orleans.TestingHost" Version="8.2.0" />
2424
<PackageReference Update="Microsoft.Orleans.Reminders" Version="8.2.0" />
25+
<PackageReference Update="Microsoft.Orleans.Persistence.Memory" Version="8.2.0" />
26+
<PackageReference Update="Microsoft.Orleans.Server" Version="8.2.0" />
2527

2628
<PackageReference Update="System.Buffers" Version="4.5.1" />
2729
<PackageReference Update="System.Runtime.Loader" Version="4.3.0" />

examples/Transfer.Client/Program.cs

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
using System.Linq;
55
using System.Threading.Tasks;
66
using IdGen;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.Extensions.Hosting;
79
using Microsoft.Extensions.Logging;
810
using Orleans;
11+
using Orleans.Hosting;
912
using Transfer.IGrains.Common;
1013
using Transfer.IGrains.DTx;
1114

@@ -14,10 +17,11 @@ namespace Transfer.Client
1417
internal class Program
1518
{
1619
private static readonly IdGenerator IdGen = new IdGenerator(0);
20+
private static IHost _host;
1721

1822
private static async Task Main(string[] args)
1923
{
20-
using var client = await StartClientWithRetries();
24+
var client = await StartClientWithRetries();
2125

2226
while (true)
2327
{
@@ -31,7 +35,12 @@ private static async Task Main(string[] args)
3135
{
3236
await DTx(client);
3337
}
38+
else
39+
{
40+
break;
41+
}
3442
}
43+
_host.Dispose();
3544
}
3645

3746
private static async Task Normal(IClusterClient client)
@@ -46,23 +55,28 @@ private static async Task Normal(IClusterClient client)
4655
var topupTaskList = new List<Task>();
4756
foreach (var account in Enumerable.Range(0, accountCount))
4857
{
49-
topupTaskList.AddRange(Enumerable.Range(0, times).Select(x => client.GetGrain<IAccount>(account).TopUp(100, IdGen.CreateId().ToString())));
58+
topupTaskList.AddRange(Enumerable.Range(0, times).Select(x =>
59+
client.GetGrain<IAccount>(account).TopUp(100, IdGen.CreateId().ToString())));
5060
}
5161

5262
topupWatch.Start();
5363
await Task.WhenAll(topupTaskList);
5464
topupWatch.Stop();
55-
Console.WriteLine($"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
65+
Console.WriteLine(
66+
$"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
5667
foreach (var account in Enumerable.Range(0, accountCount))
5768
{
58-
Console.WriteLine($"The balance of account {account} is{await client.GetGrain<IAccount>(account).GetBalance()}");
69+
Console.WriteLine(
70+
$"The balance of account {account} is{await client.GetGrain<IAccount>(account).GetBalance()}");
5971
}
6072

6173
var transferWatch = new Stopwatch();
6274
var transferTaskList = new List<Task>();
6375
foreach (var account in Enumerable.Range(0, accountCount))
6476
{
65-
transferTaskList.AddRange(Enumerable.Range(0, times).Select(x => client.GetGrain<IAccount>(account).Transfer(account + accountCount, 50, IdGen.CreateId().ToString())));
77+
transferTaskList.AddRange(Enumerable.Range(0, times).Select(x =>
78+
client.GetGrain<IAccount>(account)
79+
.Transfer(account + accountCount, 50, IdGen.CreateId().ToString())));
6680
}
6781

6882
transferWatch.Start();
@@ -72,12 +86,14 @@ private static async Task Normal(IClusterClient client)
7286
$"{times * accountCount}The transfer is completed, taking: {transferWatch.ElapsedMilliseconds}ms");
7387
foreach (var account in Enumerable.Range(0, accountCount))
7488
{
75-
Console.WriteLine($"The balance of account {account} is{await client.GetGrain<IAccount>(account).GetBalance()}");
89+
Console.WriteLine(
90+
$"The balance of account {account} is{await client.GetGrain<IAccount>(account).GetBalance()}");
7691
}
7792

7893
foreach (var account in Enumerable.Range(0, accountCount))
7994
{
80-
Console.WriteLine($"The balance of account {account} is{await client.GetGrain<IAccount>(account + accountCount).GetBalance()}");
95+
Console.WriteLine(
96+
$"The balance of account {account} is{await client.GetGrain<IAccount>(account + accountCount).GetBalance()}");
8197
}
8298
}
8399
catch (Exception e)
@@ -98,16 +114,19 @@ private static async Task DTx(IClusterClient client)
98114
var topupTaskList = new List<Task>();
99115
foreach (var account in Enumerable.Range(0, accountCount))
100116
{
101-
topupTaskList.AddRange(Enumerable.Range(0, times).Select(x => client.GetGrain<IDTxAccount>(account).TopUp(100, IdGen.CreateId().ToString())));
117+
topupTaskList.AddRange(Enumerable.Range(0, times).Select(x =>
118+
client.GetGrain<IDTxAccount>(account).TopUp(100, IdGen.CreateId().ToString())));
102119
}
103120

104121
topupWatch.Start();
105122
await Task.WhenAll(topupTaskList);
106123
topupWatch.Stop();
107-
Console.WriteLine($"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
124+
Console.WriteLine(
125+
$"{times * accountCount} Recharge completed, taking: {topupWatch.ElapsedMilliseconds}ms");
108126
foreach (var account in Enumerable.Range(0, accountCount))
109127
{
110-
Console.WriteLine($"The balance of account {account} is{await client.GetGrain<IDTxAccount>(account).GetBalance()}");
128+
Console.WriteLine(
129+
$"The balance of account {account} is{await client.GetGrain<IDTxAccount>(account).GetBalance()}");
111130
}
112131

113132
var transferWatch = new Stopwatch();
@@ -132,12 +151,14 @@ private static async Task DTx(IClusterClient client)
132151
$"{times * accountCount}The transfer is completed, taking: {transferWatch.ElapsedMilliseconds}ms");
133152
foreach (var account in Enumerable.Range(0, accountCount))
134153
{
135-
Console.WriteLine($"The balance of account {account} is{await client.GetGrain<IDTxAccount>(account).GetBalance()}");
154+
Console.WriteLine(
155+
$"The balance of account {account} is{await client.GetGrain<IDTxAccount>(account).GetBalance()}");
136156
}
137157

138158
foreach (var account in Enumerable.Range(0, accountCount))
139159
{
140-
Console.WriteLine($"The balance of account {account} is{await client.GetGrain<IDTxAccount>(account + accountCount).GetBalance()}");
160+
Console.WriteLine(
161+
$"The balance of account {account} is{await client.GetGrain<IDTxAccount>(account + accountCount).GetBalance()}");
141162
}
142163
}
143164
catch (Exception e)
@@ -154,13 +175,13 @@ private static async Task<IClusterClient> StartClientWithRetries(int initializeA
154175
{
155176
try
156177
{
157-
var builder = new ClientBuilder()
158-
.UseLocalhostClustering()
159-
.ConfigureApplicationParts(parts =>
160-
parts.AddApplicationPart(typeof(IAccount).Assembly).WithReferences())
178+
var builder = new HostBuilder()
179+
.UseOrleansClient(clientBuilder => clientBuilder.UseLocalhostClustering())
180+
// .ConfigureApplicationParts(parts =>
181+
// parts.AddApplicationPart(typeof(IAccount).Assembly).WithReferences())
161182
.ConfigureLogging(logging => logging.AddConsole());
162-
client = builder.Build();
163-
await client.Connect();
183+
_host = builder.Build();
184+
client = _host.Services.GetService<IClusterClient>();
164185
Console.WriteLine("Client successfully connect to silo host");
165186
break;
166187
}
@@ -181,4 +202,4 @@ private static async Task<IClusterClient> StartClientWithRetries(int initializeA
181202
return client;
182203
}
183204
}
184-
}
205+
}

examples/Transfer.Client/Transfer.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" />
7+
<PackageReference Include="Microsoft.Orleans.CodeGenerator" />
88
</ItemGroup>
99

1010
<ItemGroup>

examples/Transfer.Grains/Transfer.Grains.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" />
7+
<PackageReference Include="Microsoft.Orleans.CodeGenerator" />
88
</ItemGroup>
99

1010
<ItemGroup>

examples/Transfer.Server/Program.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ private static IHost CreateHost()
4747
options.ServiceId = "Transfer";
4848
})
4949
.Configure<EndpointOptions>(options => options.AdvertisedIPAddress = IPAddress.Loopback)
50-
.ConfigureApplicationParts(parts =>
51-
{
52-
parts.AddApplicationPart(typeof(Account).Assembly).WithReferences();
53-
parts.AddApplicationPart(typeof(DIDActor).Assembly).WithReferences();
54-
parts.AddApplicationPart(typeof(StreamIdActor).Assembly).WithReferences();
55-
})
56-
.AddSimpleMessageStreamProvider("SMSProvider", options => options.FireAndForgetDelivery = true).AddMemoryGrainStorage("PubSubStore");
50+
// .ConfigureApplicationParts(parts =>
51+
// {
52+
// parts.AddApplicationPart(typeof(Account).Assembly).WithReferences();
53+
// parts.AddApplicationPart(typeof(DIDActor).Assembly).WithReferences();
54+
// parts.AddApplicationPart(typeof(StreamIdActor).Assembly).WithReferences();
55+
// })
56+
.AddMemoryStreams("SMSProvider").AddMemoryGrainStorage("PubSubStore");
5757
})
5858
.ConfigureServices(serviceCollection =>
5959
{

examples/Transfer.Server/Transfer.Server.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<ItemGroup>
99
<PackageReference Include="Microsoft.Data.Sqlite"/>
1010
<PackageReference Include="Microsoft.Extensions.Hosting" />
11-
<PackageReference Include="Microsoft.Orleans.OrleansProviders" />
12-
<PackageReference Include="Microsoft.Orleans.OrleansRuntime" />
11+
<PackageReference Include="Microsoft.Orleans.Server" />
1312
<PackageReference Include="MySqlConnector" />
1413
<PackageReference Include="Npgsql" />
1514
<PackageReference Include="Microsoft.Data.SqlClient" />
15+
<PackageReference Include="Microsoft.Orleans.Persistence.Memory" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

test/Vertex.Runtime.Test/Biz/Actors/Account.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Threading;
45
using System.Threading.Tasks;
6+
using Orleans;
57
using Vertex.Abstractions.Event;
68
using Vertex.Abstractions.Snapshot;
79
using Vertex.Runtime.Actor;
@@ -119,7 +121,7 @@ public async Task RecoverySnapshot_Test()
119121

120122
public async Task Deactivate_Test()
121123
{
122-
await this.OnDeactivateAsync();
124+
await this.OnDeactivateAsync(new DeactivationReason(DeactivationReasonCode.None, string.Empty), CancellationToken.None);
123125
await this.CreateSnapshot();
124126
}
125127

test/Vertex.Runtime.Test/Core/TestSiloConfigurations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void Configure(ISiloBuilder hostBuilder)
3434
}
3535
};
3636
}, new EventArchivePolicy("month", (name, time) => $"Vertex_Archive_{name}_{DateTimeOffset.FromUnixTimeSeconds(time):yyyyMM}".ToLower(), table => table.StartsWith("Vertex_Archive".ToLower())));
37-
}).AddSimpleMessageStreamProvider("SMSProvider", options => options.FireAndForgetDelivery = true).AddMemoryGrainStorage("PubSubStore");
37+
}).AddMemoryStreams("SMSProvider").AddMemoryGrainStorage("PubSubStore");
3838
}
3939
}
4040
}

test/Vertex.Runtime.Test/Vertex.Runtime.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<ItemGroup>
88
<PackageReference Include="Microsoft.Data.Sqlite" />
99
<PackageReference Include="Microsoft.NET.Test.Sdk" />
10-
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" />
10+
<PackageReference Include="Microsoft.Orleans.CodeGenerator" />
1111
<PackageReference Include="Microsoft.Orleans.TestingHost" />
1212
<PackageReference Include="xunit" />
1313
<PackageReference Include="xunit.runner.visualstudio" />

test/Vertex.TxRuntime.Test/Core/TestSiloConfigurations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Configure(ISiloBuilder hostBuilder)
3838
}
3939
};
4040
}, new EventArchivePolicy("month", (name, time) => $"Vertex_Archive_{name}_{DateTimeOffset.FromUnixTimeSeconds(time):yyyyMM}".ToLower(), table => table.StartsWith("Vertex_Archive".ToLower())));
41-
}).AddSimpleMessageStreamProvider("SMSProvider", options => options.FireAndForgetDelivery = true).AddMemoryGrainStorage("PubSubStore");
41+
}) .AddMemoryStreams("SMSProvider").AddMemoryGrainStorage("PubSubStore");
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)