Skip to content

Commit

Permalink
Merge pull request #1264
Browse files Browse the repository at this point in the history
Print plugin versions
  • Loading branch information
mavam authored Jan 8, 2021
2 parents fe2b690 + f42ed1c commit 4464fab
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Every entry has a category for which we use the following visual abbreviations:
spawning a new actor that processes the incoming stream of data. The
directory `plugins/example` contains an example plugin.
[#1208](https://github.com/tenzir/vast/pull/1208)
[#1264](https://github.com/tenzir/vast/pull/1264)

- 🐞 For relocatable installations, the list of schema loading paths does not
include a build-time configured path any more.
Expand Down
20 changes: 20 additions & 0 deletions libvast/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ std::vector<plugin_ptr>& get() noexcept {

// -- plugin version -----------------------------------------------------------

std::string to_string(plugin_version x) {
using std::to_string;
std::string result;
result += to_string(x.major);
result += '.';
result += to_string(x.major);
result += '.';
result += to_string(x.patch);
result += '-';
result += to_string(x.tweak);
return result;
}

bool has_required_version(const plugin_version& version) noexcept {
return plugin::version.major == version.major
&& std::tie(plugin::version.minor, plugin::version.patch,
Expand Down Expand Up @@ -109,4 +122,11 @@ plugin& plugin_ptr::operator&() noexcept {
return *instance_;
}

plugin_version plugin_ptr::version() const {
auto version_function = reinterpret_cast<::vast::plugin_version (*)()>(
dlsym(library_, "vast_plugin_version"));
VAST_ASSERT(version_function != nullptr);
return version_function();
}

} // namespace vast
21 changes: 13 additions & 8 deletions libvast/src/system/version_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "vast/config.hpp"
#include "vast/json.hpp"
#include "vast/logger.hpp"
#include "vast/plugin.hpp"

#if VAST_ENABLE_ARROW
# include <arrow/util/config.h>
Expand All @@ -41,15 +42,15 @@ namespace {
json::object retrieve_versions() {
json::object result;
result["VAST"] = VAST_VERSION;
std::ostringstream caf_v;
caf_v << CAF_MAJOR_VERSION << '.' << CAF_MINOR_VERSION << '.'
<< CAF_PATCH_VERSION;
result["CAF"] = caf_v.str();
std::ostringstream caf_version;
caf_version << CAF_MAJOR_VERSION << '.' << CAF_MINOR_VERSION << '.'
<< CAF_PATCH_VERSION;
result["CAF"] = caf_version.str();
#if VAST_ENABLE_ARROW
std::ostringstream arrow_v;
arrow_v << ARROW_VERSION_MAJOR << '.' << ARROW_VERSION_MINOR << '.'
<< ARROW_VERSION_PATCH;
result["Apache Arrow"] = arrow_v.str();
std::ostringstream arrow_version;
arrow_version << ARROW_VERSION_MAJOR << '.' << ARROW_VERSION_MINOR << '.'
<< ARROW_VERSION_PATCH;
result["Apache Arrow"] = arrow_version.str();
#else
result["Apache Arrow"] = json{};
#endif
Expand All @@ -63,6 +64,10 @@ json::object retrieve_versions() {
#else
result["jemalloc"] = json{};
#endif
json::object plugin_versions;
for (auto& plugin : plugins::get())
plugin_versions[plugin->name()] = to_string(plugin.version());
result["plugins"] = std::move(plugin_versions);
return result;
}

Expand Down
6 changes: 6 additions & 0 deletions libvast/vast/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ extern "C" struct plugin_version {
uint16_t tweak;
};

/// @relates plugin_version
std::string to_string(plugin_version x);

/// Checks if a version meets the plugin version requirements.
/// @param version The version to compare against the requirements.
bool has_required_version(const plugin_version& version) noexcept;
Expand Down Expand Up @@ -155,6 +158,9 @@ class plugin_ptr final {
return dynamic_cast<Plugin*>(instance_);
}

/// Returns the plugin version.
plugin_version version() const;

private:
/// Implementation details.
void* library_ = {};
Expand Down

0 comments on commit 4464fab

Please sign in to comment.