ConfD User Community

Libconfd and xml input


#1

We use libconfd version 3.7.1 in our application to connect to the confd server and read the configuration.
Especially with unit tests, it is not always feasible for us to connect to a server, and would like libconfd to read the configuration from an xml file generated originally from the cli.

Is that possible? And if so - how?

Thanks


#2

Not possible, but since the libconfd source code comes with ConfD you can create a modified variant of libconfd to fit your unit test needs. Or just run ConfD with your unit tests which is what most if not everyone does.


#3

Agreed, (almost) anything is possible with a bit of programming, but in this case you may probably just as well write something from scratch. If you actually look at that source, you’ll find that most of at least the MAAPI and CDB APIs are fairly thin wrappers that just encodes the function arguments into a request that is sent on the socket to ConfD, and decodes the reply that comes back into return data. It doesn’t actually “know” that it is reading configuration or whatever, and certainly has no idea that the configuration could alternately be represented as xml.

That would certainly be the recommended approach.