Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.8.0
-
None
Description
A function zoo_version_str would be useful for the same reasons that librdkafka has a rd_kafka_version_str, in short, for when a program has dynamically loaded libzookeeper_mt.so and wants to verify that it provides the expected api version that the calling program was compiled against.
It is true that zookeeper-native binary package usually contains the /usr/include/zookeeper files but that is not always the case and even so provides a more complex scanning issue than simply calling an api function.
Here is the full source code needed to implement this function as a patch to 3.5 and earlier.
#define STR1(x) STR2(x) #define STR2(x) #x const char *zoo_version_str() { return STR1(ZOO_MAJOR_VERSION) "." STR1(ZOO_MINOR_VERSION) "." STR1(ZOO_PATCH_VERSION); }
This function would also be used by any language using a libffi style solution, of which there are many. In this case you preprocess the /usr/include/zookeeper files into an application binary interface (ABI) and then at runtime you must ensure that your ABI matches the API version for the dynamic library which you want to consume.
The implementation for the master branch and 3.6 and later is
const char *zoo_version_str() { return ZOO_VERSION; }