Skip to content

Commit

Permalink
feat(*): upgrade dotnet 8 + orleans 8 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
claylaut authored Feb 6, 2024
1 parent ad8394d commit 0524ceb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Orleans.Sdk" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Server" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.TestingHost" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Server" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.TestingHost" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
44 changes: 22 additions & 22 deletions Orleans.Persistence.Redis/Config/RedisSiloHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ string name
public static RedisStorageOptionsBuilder AddRedisGrainStorageAsDefault(
this ISiloBuilder builder
) => builder.AddRedisGrainStorage("Default");

internal static IServiceCollection AddRedisGrainStorage(
this IServiceCollection services,
string name,
Expand All @@ -38,24 +38,24 @@ internal static IServiceCollection AddRedisGrainStorage(
{
configureOptions?.Invoke(services.AddOptions<RedisStorageOptions>(name));
// services.AddTransient<IConfigurationValidator>(sp => new DynamoDBGrainStorageOptionsValidator(sp.GetService<IOptionsSnapshot<RedisStorageOptions>>().Get(name), name));
services.AddSingletonNamedService(name, CreateStateStore);
services.AddKeyedSingleton(name, CreateStateStore);
services.ConfigureNamedOptionForLogging<RedisStorageOptions>(name);
services.TryAddSingleton(sp =>
sp.GetServiceByName<IGrainStorage>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME));
sp.GetKeyedService<IGrainStorage>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME));

return services
.AddSingletonNamedService(name, CreateDbConnection)
.AddSingletonNamedService(name, CreateRedisStorage)
.AddSingletonNamedService(name, (provider, n)
=> (ILifecycleParticipant<ISiloLifecycle>)provider.GetRequiredServiceByName<IGrainStorage>(n));
.AddKeyedSingleton(name, CreateDbConnection)
.AddKeyedSingleton(name, CreateRedisStorage)
.AddKeyedSingleton(name, (provider, n)
=> (ILifecycleParticipant<ISiloLifecycle>)provider.GetRequiredKeyedService<IGrainStorage>(n));
}

internal static ISiloBuilder AddRedisDefaultSerializer(this ISiloBuilder builder, string name)
=> builder.AddRedisSerializer<OrleansSerializer>(name);

internal static ISiloBuilder AddRedisDefaultBrotliSerializer(this ISiloBuilder builder, string name)
=> builder.AddRedisSerializer<BrotliSerializer>(name);

internal static ISiloBuilder AddRedisDefaultHumanReadableSerializer(this ISiloBuilder builder, string name)
=> builder.AddRedisHumanReadableSerializer<JsonSerializer>(
name,
Expand All @@ -65,7 +65,7 @@ internal static ISiloBuilder AddRedisDefaultHumanReadableSerializer(this ISiloBu
internal static ISiloBuilder AddCompression<TCompression>(this ISiloBuilder builder, string name)
where TCompression : ICompression
=> builder.ConfigureServices(services =>
services.AddSingletonNamedService<ICompression>(name, (provider, n)
services.AddKeyedSingleton<ICompression>(name, (provider, n)
=> ActivatorUtilities.CreateInstance<TCompression>(provider)));

internal static ISiloBuilder AddRedisSerializer<TSerializer>(
Expand All @@ -75,7 +75,7 @@ params object[] settings
)
where TSerializer : ISerializer
=> builder.ConfigureServices(services =>
services.AddSingletonNamedService<ISerializer>(name, (provider, n)
services.AddKeyedSingleton<ISerializer>(name, (provider, n)
=> ActivatorUtilities.CreateInstance<TSerializer>(provider, settings))
);

Expand All @@ -86,7 +86,7 @@ params object[] settings
)
where TSerializer : IHumanReadableSerializer
=> builder.ConfigureServices(services =>
services.AddSingletonNamedService<IHumanReadableSerializer>(name, (provider, n)
services.AddKeyedSingleton<IHumanReadableSerializer>(name, (provider, n)
=> ActivatorUtilities.CreateInstance<TSerializer>(provider, settings))
);

Expand All @@ -96,24 +96,24 @@ internal static ISiloBuilder AddRedisHumanReadableSerializer<TSerializer>(
Func<IServiceProvider, object[]> cfg
) where TSerializer : IHumanReadableSerializer
=> builder.ConfigureServices(services =>
services.AddSingletonNamedService<IHumanReadableSerializer>(name, (provider, n)
services.AddKeyedSingleton<IHumanReadableSerializer>(name, (provider, n)
=> ActivatorUtilities.CreateInstance<TSerializer>(provider, cfg?.Invoke(provider)))
);

private static IGrainStorage CreateRedisStorage(IServiceProvider services, string name)
{
var store = services.GetRequiredServiceByName<IGrainStateStore>(name);
var connection = services.GetRequiredServiceByName<DbConnection>(name);
var store = services.GetRequiredKeyedService<IGrainStateStore>(name);
var connection = services.GetRequiredKeyedService<DbConnection>(name);
return ActivatorUtilities.CreateInstance<RedisGrainStorage>(services, name, store, connection);
}

private static IGrainStateStore CreateStateStore(IServiceProvider provider, string name)
{
var connection = provider.GetRequiredServiceByName<DbConnection>(name);
var serializer = provider.GetRequiredServiceByName<ISerializer>(name);
var humanReadableSerializer = provider.GetServiceByName<IHumanReadableSerializer>(name);
var options = provider.GetRequiredService<IOptionsSnapshot<RedisStorageOptions>>();
var logger = provider.GetRequiredService<ILogger<GrainStateStore>>();
private static IGrainStateStore CreateStateStore(IServiceProvider provider, string name)
{
var connection = provider.GetRequiredKeyedService<DbConnection>(name);
var serializer = provider.GetRequiredKeyedService<ISerializer>(name);
var humanReadableSerializer = provider.GetKeyedServices<IHumanReadableSerializer>(name);
var options = provider.GetRequiredService<IOptionsSnapshot<RedisStorageOptions>>();
var logger = provider.GetRequiredService<ILogger<GrainStateStore>>();

return ActivatorUtilities.CreateInstance<GrainStateStore>(
provider,
Expand Down
4 changes: 2 additions & 2 deletions Orleans.Persistence.Redis/Core/GrainStateStore.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using ByteSizeLib;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Orleans.Persistence.Redis.Compression;
using Orleans.Persistence.Redis.Config;
using Orleans.Persistence.Redis.Serialization;
using Orleans.Persistence.Redis.Utils;
using Orleans.Runtime;
using Orleans.Storage;
using StackExchange.Redis;
using System.Text;
Expand Down Expand Up @@ -41,7 +41,7 @@ IServiceProvider services
_humanReadableSerializer = humanReadableSerializer;
_logger = logger;
_options = options;
_compression = services.GetServiceByName<ICompression>(name);
_compression = services.GetKeyedService<ICompression>(name);
}

public async Task<IGrainState<T>> GetGrainState<T>(string grainId, Type stateType)
Expand Down
4 changes: 2 additions & 2 deletions Orleans.Persistence.Redis/Orleans.Persistence.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<ItemGroup>
<!--<PackageReference Include="Brotli.NET" Version="2.1.1" />-->
<PackageReference Include="MessagePack" Version="2.5.140" />
<PackageReference Include="Microsoft.Orleans.Runtime" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Runtime" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
<PackageReference Include="StackExchange.Redis" Version="2.7.17" />
<PackageReference Include="System.Data.HashFunction.xxHash" Version="2.0.0" />
<PackageReference Include="ByteSize" Version="2.1.2" />
Expand Down
2 changes: 1 addition & 1 deletion Samples/TestClient/TestClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/TestGrains/TestGrains.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Orleans.Sdk" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Samples/TestSilo/TestSilo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Server" Version="7.2.2" />
<PackageReference Include="Microsoft.Orleans.Server" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 0524ceb

Please sign in to comment.