1
#include "source/extensions/stat_sinks/hystrix/config.h"
2

            
3
#include <memory>
4

            
5
#include "envoy/config/metrics/v3/stats.pb.h"
6
#include "envoy/config/metrics/v3/stats.pb.validate.h"
7
#include "envoy/registry/registry.h"
8

            
9
#include "source/extensions/stat_sinks/hystrix/hystrix.h"
10

            
11
namespace Envoy {
12
namespace Extensions {
13
namespace StatSinks {
14
namespace Hystrix {
15

            
16
absl::StatusOr<Stats::SinkPtr>
17
HystrixSinkFactory::createStatsSink(const Protobuf::Message& config,
18
4
                                    Server::Configuration::ServerFactoryContext& server) {
19
4
  const auto& hystrix_sink =
20
4
      MessageUtil::downcastAndValidate<const envoy::config::metrics::v3::HystrixSink&>(
21
4
          config, server.messageValidationContext().staticValidationVisitor());
22
4
  return std::make_unique<Hystrix::HystrixSink>(server, hystrix_sink.num_buckets());
23
4
}
24

            
25
7
ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() {
26
7
  return std::make_unique<envoy::config::metrics::v3::HystrixSink>();
27
7
}
28

            
29
9
std::string HystrixSinkFactory::name() const { return HystrixName; }
30

            
31
/**
32
 * Static registration for the statsd sink factory. @see RegisterFactory.
33
 */
34
REGISTER_FACTORY(HystrixSinkFactory, Server::Configuration::StatsSinkFactory);
35

            
36
} // namespace Hystrix
37
} // namespace StatSinks
38
} // namespace Extensions
39
} // namespace Envoy