Section Providers

The server uses Section Providers to get the data that it needs to serve to clients, as well as the section mapping that tells it what sections there are and how to get them.

There is one provider included so far, "FileProvider". This is very simple and just reads files from the local disk. Internally we also use a TFS provider for reading data out of Team Foundation source control, as well as a SQL provider. Because of code dependency and redistribution issues they are not currently released, but I hope to find a way to package and release at least the TFS provider in a way that doesn't cause initial builds to be difficult for users.

Adding a new provider is very simple: create a public class that implements MySpace.ConfigurationSystem.IConfigurationSystemSectionProvider and put the assembly in the runtime folder of the server. On startup the server scans the folder for these classes so they can be used.

To use your provider for sections, simple use the name of the class as the provider attribute of your section definition and set the source to whatever string your provider understands. To user a new provider to read the section mapping use the mappingConfigPath and mappingConfigProvider attributes of your ConfigurationSystemServerConfig in a similar fashion.

The interface itself is defined in MySpace.ConfigurationSystem.Server.dll and is very simple - just one method!

bool TryGetDataBytes(string itemPath, out byte[] dataBytes, out string errorMessage);

itemPath will be the source value for the section that's being requested. If your provider successfully read the data, you should set dataBytes to the bytes that will be returned to the client and return true. If there was an error you should set errorMessage to a description of the problem and return false.

The server keeps a cache of local items in order to deal with intermittent provider issues, but if it has no entry in its cache and TryGetDataBytes returns false, then the contents of errorMessage will be returned to the client in a 500 error.

Last edited May 24, 2011 at 11:48 PM by eriknelson, version 3

Comments

No comments yet.