Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: What are grain extensions and how can they be used? #1971

Closed
Eldar1205 opened this issue Jul 21, 2016 · 3 comments
Closed

Question: What are grain extensions and how can they be used? #1971

Eldar1205 opened this issue Jul 21, 2016 · 3 comments
Labels

Comments

@Eldar1205
Copy link

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?

@ReubenBond
Copy link
Member

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.

@gabikliot
Copy link
Contributor

Mixin, exactly.

@Eldar1205
Copy link
Author

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
#1971 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFBYt6R8rdcr3v968VJG7sGuRz6KBXTfks5qYBp3gaJpZM4JSLMO
.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants