Horusiath/AkkaCQRS

Extension

Closed this issue · 2 comments

I have seen the pattern of extending a class through inheritance by deriving the class from a base class of similar type. For example, in WebAPI a CustomerController is derived from APIController. The class Extension and ExtensionProvider has confused me. To me, it is more like configuring a run time object but the name Configure would have been more appropriate?

Could you please explain the CqrsExtension achieved with InjectTopLevelFallback?

Both Akka and Akka.NET have a mechanism of custom plugins called extensions, allowing to define custom behavior on actor system level. Examples of such are Persistence, Remoting, Cluster etc. IExtension is the interface, custom plugin must implement in order to be be used by actor system, while ExtensionIdProvider<> works similar to factory pattern.

Since total HOCON configuration for actor system may be present in many HOCON config strings, and some of the key-value pairs may repeat in them, therefore their importance is based on their order. Just like config1.WithFallback(config2) method is used to place config2 after config1, so InjectTopLevelFallback is used to place configuration right after the first HOCON config in the chain (which is user-defined one passed inside ActorSystem.Create(name, hoconConfig) expression).

Thanks. You're awesome!