dotnet / dotnet/orleans

Add the ability to set which implementing grain matches an interface explicitly in testing.

Open
#7,502 6 comments 0 reactions 1 assignee Claimed by @ReubenBond View on GitHub
area-grains question
Dominant language
C#
Stars
10.9k
Forks
2.1k
Avg merge
13h 56m
Merged PRs (30d)
351

Description

Hey,

When testing we would like the ability to replace the implementation of a grain interface with another that matches the interface. For example:

```csharp
public interface ISomethingGrain
{
public Task DoSomething();
}

public class MyActualGrain : ISomethingGrain
{
public async Task DoSomething()
{
// Some Work
await Task.Delay(100);
}
}

public class MyOtherGrain : ISomethingGrain
{
public async Task DoSomething()
{
// Some Test Verification
await Task.Delay(100);
// Some Work
await Task.Delay(100);
}
}

// When configuring a test cluster add a redirect to MyOtherGrain
public class SiloConfigurator : ISiloConfigurator
{
public void Configure(ISiloBuilder siloBuilder)
{
siloBuilder
.AddGrainRedirect();
}
}
```

At the moment we can simulate something like this by either using a `IIncomingGrainCallFilter` and redirect calls from one to the other. Or we can register a grain with the same name as the interface since Orleans chooses the primary implementation as the last registration where the name matches the interface, without the I. This is a little brittle since we can't be sure that this can change at any time understandably.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.