I have the following (simplified) architecture:
client(s) --> bouncer --> server
The clients send commands to the server. The 'bouncer' performs sanity and other checks on the commands issued by the client, and prevents faulty commands from reaching the server. For example, the bouncer may have the following code:
bool Bouncer::someCommand(const someCommandArg& arg) {
if (arg.x < 100) {
return false;
}
if (arg.y > 10) {
return false;
}
// more checks ...
return server->someCommand(arg);
}
The problem with this approach is that the bouncer conditions have to be hard-coded one by one, and is not flexible enough. I'm looking for a way to define these conditions in some configuration file, which the bouncer will load when created, and will loop through all the
conditions when someCommand
is called. Moreover, the test loop itself has to be fast.
Were it C#, I guess I would have used its compile-on-the-fly capabilities, and have my if
clauses written in plain code in the configuration file. What do you suggest for C++?
Choices include:
What's best depends a lot on the complexity of useful predicates, performance requirements, deployment practices etc..