orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Grain Disambiguation

Open w14525555 opened this issue 8 years ago • 2 comments

I am working on the project that some grain implementations inherit from an abstract grain implementation . Some just like this: public abstract class A: Grain, IGrainInterface { abstract method(); }

public class B: A { override method(); }

public class C: A { override method() }

It seems I can use a grainClassNamePrefix to solve this problem, but I haven't found any documents to describe how to use it.

Thanks!

w14525555 avatar Jun 19 '18 22:06 w14525555

You can pass a fully qualified class name to GetGrain() as optional parameter:

GetGrain<IGrainInterface>(key, "your-namespace.B");
GetGrain<IGrainInterface>(key, "your-namespace.C");

or just a prefix of the fully qualified name, if the grain classes are defined in different namespaces:

GetGrain<IGrainInterface>(key, "B-namespace");
GetGrain<IGrainInterface>(key, "C-namespace");

The namespace approach works well for switching between different implementations of multiple grain classes, for example, between test and production.

sergeybykov avatar Jun 19 '18 23:06 sergeybykov

@sergeybykov It works. Thanks a lot!

w14525555 avatar Jun 20 '18 06:06 w14525555