Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-4556

function zoo_version_str

    XMLWordPrintableJSON

Details

    • Hide
      extern ZOOAPI const char *zoo_version_str();
      Returns a string "MAJOR.MINOR.PATCH" representing the values at compile time for the zookeeper C client library.
      Show
      extern ZOOAPI const char *zoo_version_str(); Returns a string "MAJOR.MINOR.PATCH" representing the values at compile time for the zookeeper C client library.

    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;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            gjcarrette George J Carrette
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Time Spent - 50m Remaining Estimate - 1h 10m
                1h 10m
                Logged:
                Time Spent - 50m Remaining Estimate - 1h 10m
                50m