You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/metrics/json_publisher.hpp

41 lines
832 B
C++

#ifndef LLARP_METRICS_JSON_PUBLISHER_HPP
#define LLARP_METRICS_JSON_PUBLISHER_HPP
#include <util/fs.hpp>
#include <util/metrics_core.hpp>
#include <nlohmann/json.hpp>
#include <functional>
#include <iosfwd>
#include <utility>
namespace llarp
{
namespace metrics
{
class JsonPublisher final : public Publisher
{
public:
using PublishFunction = std::function< void(const nlohmann::json&) >;
private:
PublishFunction m_publish;
public:
JsonPublisher(PublishFunction publish) : m_publish(std::move(publish))
{
}
~JsonPublisher() override = default;
void
publish(const Sample& values) override;
static void
directoryPublisher(const nlohmann::json& result, const fs::path& path);
};
} // namespace metrics
} // namespace llarp
#endif