The examples you presented suggest that you might need some kind of rule engine. To show what I mean, I interpret your examples as having the following semantics:
if (true) { Client_Id = "ABC"; } if (User_Type == "Admin" && Region == "Mumbai" && "User_rating" == "9") { Commission = "10%"; } if (User_Id == "123") { WhitelistedRegions" = ["Mumbai", "Goa"]; }
If my interpretation is incorrect, perhaps you can edit your question to clarify your intended meaning. On the other hand, if my interpretation is correct, then I donβt know any specific configuration syntax specifically designed for your requirements. Instead, I suspect that you will have to tailor the semantics of what you want into the limitations of any configuration syntax that you decide to use.
How can I try to explain (your interpretations) your examples in the Config4 * syntax (disclaimer: I am its main developer) is as follows:
uid-rule { # unconditional client_Id = "ABC"; } uid-rule { condition { User_Type = "Admin"; Region = "Mumbai"; User_rating = "9"; } Commission = "10%%"; } uid-rule { condition { User_Id = "123"; } WhitelistedRegions = ["Mumbai", "Goa"]; }
I recommend that you read Chapter 2 of the Config4 * Getting Started ( HTML , PDF ) manual so that you can understand the syntax used in the above example.
My initial attempt to train your examples in XML syntax:
<rules> <rule> <property name="client_Id" value="ABC"/> </rule> <rule> <condition name="User_Type" value="Admin"/> <condition name="Region" value="Mumbai"/> <condition name="User_rating" value="9"/> <property name="Commission" value="10%"/> </rule> <rule> <condition name="User_Id" value="123"/> <property name="WhitelistedRegions" value="Mumbai, Goa"/> </rule> </rules>
Please note that neither the Config4 * parser nor the XML parser will provide you with the semantics that you want to get out of the box. Instead, you should write a class called RulesEngine . Such a class: (1) analyzes the configuration file to obtain rules and caches the analyzed representation in memory; (2) provide a simple API for requesting this set of rules in memory; and (3) provide a reloadConfiguration() method that reassembles the configuration file. Your application will somehow call the reloadConfiguration() method call (for example, every few minutes).
If you use XML for configuration syntax, I suggest that you achieve the goal of centralization by storing the XML file on a web server. An XML parser can get the file form there. If you use the Config4 * syntax, then integrating Config4 * with curl allows you to do the same.