Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/access_log/access_log.h" 4 : #include "envoy/extensions/health_check/event_sinks/file/v3/file.pb.h" 5 : #include "envoy/extensions/health_check/event_sinks/file/v3/file.pb.validate.h" 6 : #include "envoy/upstream/health_check_event_sink.h" 7 : 8 : namespace Envoy { 9 : namespace Upstream { 10 : 11 : class HealthCheckEventFileSink : public HealthCheckEventSink { 12 : public: 13 : explicit HealthCheckEventFileSink( 14 : const envoy::extensions::health_check::event_sinks::file::v3::HealthCheckEventFileSink& 15 : config, 16 : AccessLog::AccessLogManager& log_manager) 17 : : file_(log_manager.createAccessLog(Filesystem::FilePathAndType{ 18 0 : Filesystem::DestinationType::File, config.event_log_path()})) {} 19 : 20 : void log(envoy::data::core::v3::HealthCheckEvent event) override; 21 : 22 : private: 23 : AccessLog::AccessLogFileSharedPtr file_; 24 : }; 25 : 26 : class HealthCheckEventFileSinkFactory : public HealthCheckEventSinkFactory { 27 : public: 28 2 : HealthCheckEventFileSinkFactory() = default; 29 : 30 : HealthCheckEventSinkPtr 31 : createHealthCheckEventSink(const ProtobufWkt::Any& config, 32 : Server::Configuration::HealthCheckerFactoryContext& context) override; 33 : 34 38 : std::string name() const override { return "envoy.health_check.event_sink.file"; } 35 : 36 1 : ProtobufTypes::MessagePtr createEmptyConfigProto() override { 37 1 : return ProtobufTypes::MessagePtr{ 38 1 : new envoy::extensions::health_check::event_sinks::file::v3::HealthCheckEventFileSink()}; 39 1 : } 40 : }; 41 : 42 : } // namespace Upstream 43 : } // namespace Envoy