Skip to content

Commit

Permalink
Upgrade Orleans to version 8.1.0 (#160) (#161)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Konecki <jakub.konecki@halny.tech>
  • Loading branch information
jkonecki and Jakub Konecki authored Apr 18, 2024
1 parent ee3095b commit 72003a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/OrleansTestKit/OrleansTestKit.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand All @@ -12,7 +12,7 @@
<PackageTags>Orleans Cloud-Computing Actor-Model Actors Distributed-Systems C# .NET Test Testing</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>8.0.0</Version>
<Version>8.1.0</Version>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -24,9 +24,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Orleans.Reminders" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Streaming" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Runtime" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Reminders" Version="8.1.0" />
<PackageReference Include="Microsoft.Orleans.Streaming" Version="8.1.0" />
<PackageReference Include="Microsoft.Orleans.Runtime" Version="8.1.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
6 changes: 3 additions & 3 deletions src/OrleansTestKit/Reminders/ReminderContextHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private ReminderContextHolder()
_slim = new SemaphoreSlim(1);
var assembly = typeof(GrainId).Assembly;
var contextType = assembly.GetType(RuntimeNamespace)!;
_runtimeContextMethod = contextType.GetMethod(RuntimeMethod, BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(IGrainContext) })!;
_runtimeContextMethod = contextType.GetMethod(RuntimeMethod, BindingFlags.NonPublic | BindingFlags.Static)!;
}

public static ReminderContextHolder Instance =>
Expand All @@ -33,7 +33,7 @@ public void ReleaseReminderContext()
{
try
{
_runtimeContextMethod.Invoke(null, new object?[] { null });
_runtimeContextMethod.Invoke(null, new object?[] { null, null });
}
finally
{
Expand All @@ -44,6 +44,6 @@ public void ReleaseReminderContext()
public async Task SetReminderContext(IGrainContext context, CancellationToken token = default)
{
await _slim.WaitAsync(token);
_runtimeContextMethod.Invoke(null, new object[] { context });
_runtimeContextMethod.Invoke(null, new object?[] { context, null });
}
}
12 changes: 7 additions & 5 deletions src/OrleansTestKit/Utilities/RuntimeContextManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ namespace Orleans.TestKit.Reminders;

internal sealed class RuntimeContextManager
{
public delegate void SetExecutionContextAction(IGrainContext? newContext, out IGrainContext currentContext);

private RuntimeContextManager()
{
var assembly = typeof(GrainId).Assembly;
var contextType = assembly.GetType("Orleans.Runtime.RuntimeContext")!;

SetExecutionContext = contextType
.GetMethod("SetExecutionContext", BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(IGrainContext) })!
.CreateDelegate<Action<IGrainContext?>>()
.GetMethod("SetExecutionContext", BindingFlags.NonPublic | BindingFlags.Static)!
.CreateDelegate<SetExecutionContextAction>()
;
}

public static RuntimeContextManager Instance { get; } = new RuntimeContextManager();

public Action<IGrainContext?> SetExecutionContext { get; }
public SetExecutionContextAction SetExecutionContext { get; }

public static IDisposable StartExecutionContext(IGrainContext context) => new RuntimeContextScope(context);

public void ResetExecutionContext() => SetExecutionContext(null);
public void ResetExecutionContext() => SetExecutionContext(null, out _);

private sealed class RuntimeContextScope : IDisposable
{
public RuntimeContextScope(IGrainContext context) => Instance.SetExecutionContext(context);
public RuntimeContextScope(IGrainContext context) => Instance.SetExecutionContext(context, out _);

public void Dispose() => Instance.ResetExecutionContext();
}
Expand Down
2 changes: 1 addition & 1 deletion test/OrleansTestKit.Tests/OrleansTestKit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.CodeCoverage" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.0.0" />
<PackageReference Include="Microsoft.Orleans.Sdk" Version="8.1.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="xunit" Version="2.6.5" />
Expand Down

0 comments on commit 72003a7

Please sign in to comment.