lokinet/llarp/util/metrics/json_publisher.hpp

41 lines
832 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-09-01 12:58:27 +00:00
#include <util/metrics/core.hpp>
2019-02-27 21:46:23 +00:00
#include <nlohmann/json.hpp>
2019-04-07 17:54:33 +00:00
#include <functional>
2019-02-27 21:46:23 +00:00
#include <iosfwd>
2019-07-30 23:42:13 +00:00
#include <utility>
2019-02-27 21:46:23 +00:00
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:
2019-07-30 23:42:13 +00:00
JsonPublisher(PublishFunction publish) : m_publish(std::move(publish))
2019-04-07 17:54:33 +00:00
{
}
2019-07-30 23:42:13 +00:00
~JsonPublisher() override = default;
2019-04-07 17:54:33 +00:00
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