mirror of https://github.com/oxen-io/lokinet
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.
60 lines
1.0 KiB
C++
60 lines
1.0 KiB
C++
6 years ago
|
#ifndef LLARP_METRICS_PUBLISHERS_HPP
|
||
|
#define LLARP_METRICS_PUBLISHERS_HPP
|
||
|
|
||
|
#include <util/metrics_core.hpp>
|
||
|
|
||
6 years ago
|
#include <util/fs.hpp>
|
||
|
|
||
6 years ago
|
#include <iosfwd>
|
||
6 years ago
|
#include <nlohmann/json.hpp>
|
||
6 years ago
|
|
||
|
namespace llarp
|
||
|
{
|
||
|
namespace metrics
|
||
|
{
|
||
|
class StreamPublisher final : public Publisher
|
||
|
{
|
||
|
std::ostream& m_stream;
|
||
|
|
||
|
public:
|
||
|
StreamPublisher(std::ostream& stream) : m_stream(stream)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
~StreamPublisher()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void
|
||
|
publish(const Sample& values) override;
|
||
|
};
|
||
6 years ago
|
|
||
|
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
|
||
|
directoryPublisher(const nlohmann::json& result, fs::path path);
|
||
|
};
|
||
6 years ago
|
} // namespace metrics
|
||
|
|
||
|
} // namespace llarp
|
||
|
|
||
|
#endif
|