Member-only story
Microsoft Orleans — Observers
As we continue exploring Microsoft Orleans — the virtual actor model framework — we happen upon Observers. Observers can be used to “observe” events, in the form of notifications, as an example.
Orleans observers are build by creating an interface that implements the Orleans’ namespaces’ IGrainObserver
interface. Observer methods must have a void
return type, and can be invoked via a grain when “something” happens, in the form of a method call.
The Orleans Observers documentation can be found:
What we’ll need
There are a few steps to setting up an observer and a grain that can manage observers:
- New interface that implements
IGrainObserver
, and a class the implements the new interface. - A new grain interface and grain that provide a subscribe, unsubscribe, and notify like method.
- A class to manage registered observers.
- A method of using the above observer.