Closed Eldar1205 closed 8 years ago
Grain extensions are a very cool feature. I learned the ins-and-outs of them while writing #1916.
Grain extensions are a way to attach behaviors to grains. It's basically the component pattern, or like a mixin.
For example, I attach an IObserverGrainExtension
to a grain so that I can send OnNextAsync
/etc calls to a grain which are then translated into calls to the observer object in the grain itself.
As another example, For Orleans.Consensus (a Raft implementation), we may end up adding an extension which implements the Raft RPCs so that individual grains can become replicated state machines without having to implement a distributed consensus algorithm themselves.
In the framework, IGrainExtension
is currently used for Streams support and CancellationToken
support.
Currently, grain extensions are not accessible from external code - they cannot be registered without having internal access to Orleans. #1916 includes a change which makes a new interface, IGrainExtensionManager
accessible through DI - so grains would be able to take advantage of extensions.
Mixin, exactly.
Thanks for explanation. Sounds very interesting and useful. בתאריך 22 ביול' 2016 4:18, "Gabriel Kliot" notifications@github.com כתב:
Mixin, exactly.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dotnet/orleans/issues/1971#issuecomment-234430145, or mute the thread https://github.com/notifications/unsubscribe-auth/AFBYt6R8rdcr3v968VJG7sGuRz6KBXTfks5qYBp3gaJpZM4JSLMO .
In Orleans Interceptors documentation it is specified at the end that "Grain-level interceptors will also be invoked for grain extensions (implementations of IGrainExtension), not only for method in the current class." What are those IGrainExtension implementations used for? How can they be registered to a grain?