-
Notifications
You must be signed in to change notification settings - Fork 14
Configuration api
Both of client side and server side, configuration is exposed via Configuration API, namely RpcClientConfiguration and RpcServerConfiguration.
This API is pretty straightforward, but you should know a little rules.
Although configuration change after start is very handy, it is easy to confuse and then causes unstability. At the same time, configuration object is naturally mutable (since it is a kind of property bag). To resolve these problem, configuration object is Freezable that means if the object is frozen, attemtping to modify value will be fail.
Configuration API defines providers as generic Func<> delegates which takes configuration object itself and common parameters and returns target object. Providers represent essentially factory method, but it should ensure that consumers and providers do not assume anything -- consumer might cache returned value, or provider returns singleton object, for example.
By design, RpcClient/ServerConfiguration is NOT derived from ConfigurationElement to decouple from specific configuration runtime. In addition, configuration method should be application specific instead of library/runtime specific.
If you externalize configuration like *.config file, you want to implement custom ConfigurationSection to handle it. And then, you fetch values from ConfigurationManager and set to own RpcClient/ServerConfiguration object.