lokinet/llarp/metrics/json_publisher.hpp

42 lines
805 B
C++
Raw Normal View History

#ifndef LLARP_METRICS_JSON_PUBLISHER_HPP
#define LLARP_METRICS_JSON_PUBLISHER_HPP
2019-02-27 21:46:23 +00:00
#include <util/fs.hpp>
2019-02-27 21:46:23 +00:00
#include <util/metrics_core.hpp>
#include <nlohmann/json.hpp>
2019-04-07 17:54:33 +00:00
#include <functional>
2019-02-27 21:46:23 +00:00
#include <iosfwd>
namespace llarp
{
namespace metrics
{
2019-04-07 17:54:33 +00:00
class JsonPublisher final : public Publisher
{
public:
using PublishFunction = std::function< void(const nlohmann::json&) >;
private:
PublishFunction m_publish;
public:
JsonPublisher(const PublishFunction& publish) : m_publish(publish)
{
}
~JsonPublisher()
{
}
void
publish(const Sample& values) override;
static void
2019-04-14 17:12:11 +00:00
directoryPublisher(const nlohmann::json& result, const fs::path& path);
2019-04-07 17:54:33 +00:00
};
2019-02-27 21:46:23 +00:00
} // namespace metrics
} // namespace llarp
#endif