Add the ability to set which implementing grain matches an interface explicitly in testing.
- 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
Assessment
This issue has not been assessed yet.