Skip to content

Commit

Permalink
Correctly dispose enumerator, remove unused GetGrainAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenBond committed Dec 14, 2023
1 parent 8104fc4 commit c9ceba9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 46 deletions.
45 changes: 0 additions & 45 deletions src/Orleans.Core/Core/GrainFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,51 +229,6 @@ private IAddressable GetGrain(Type interfaceType, IdSpan grainKey, string grainC
return grain;
}

internal async ValueTask<IAddressable> GetGrainAsync(GrainInterfaceType grainInterfaceType, IdSpan grainKey, string grainClassNamePrefix, CancellationToken cancellationToken)
{
GrainType grainType;
Exception lastException = null;
do
{
try
{
if (!string.IsNullOrWhiteSpace(grainClassNamePrefix))
{
grainType = this.interfaceTypeToGrainTypeResolver.GetGrainType(grainInterfaceType, grainClassNamePrefix);
}
else
{
grainType = this.interfaceTypeToGrainTypeResolver.GetGrainType(grainInterfaceType);
}
}
catch (ArgumentException ex)
{
// Not found in the type map. Maybe it's not available yet ? (heterogeneous case)
grainType = GrainTypePrefix.CreateStubGrainType(grainClassNamePrefix);
lastException = ex;
}
try
{
await Task.Delay(1_000, cancellationToken);
}
catch (TaskCanceledException)
{
break;
}
}
while (grainType.IsStubGrain() || cancellationToken.IsCancellationRequested);

if (grainType.IsStubGrain())
{
Debug.Assert(lastException != null);
throw lastException;
}

var grainId = GrainId.Create(grainType, grainKey);
var grain = this.referenceActivator.CreateReference(grainId, grainInterfaceType);
return grain;
}

/// <summary>
/// Creates a grain reference.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private async Task ResolveGrainTypeAsync(GrainReference reference, IInvokable re
_ = GrainTypePrefix.TryGetCrainClassPrefix(reference.GrainId.Type, out var grainClassPrefix);
var timeout = request.GetDefaultResponseTimeout() ?? _runtimeClient.GetResponseTimeout();
using var cancellation = new CancellationTokenSource(timeout, _timeProvider);
var clusterManifestUpdates = _clusterManifestProvider.Updates.WithCancellation(cancellation.Token).GetAsyncEnumerator();
await using var clusterManifestUpdates = _clusterManifestProvider.Updates.WithCancellation(cancellation.Token).GetAsyncEnumerator();
GrainType grainType;
while (!_interfaceTypeToGrainTypeResolver.TryGetGrainType(reference.InterfaceType, grainClassPrefix, out grainType))
{
Expand Down

0 comments on commit c9ceba9

Please sign in to comment.