Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/common/random_generator.h" 4 : #include "envoy/config/core/v3/health_check.pb.h" 5 : #include "envoy/config/typed_config.h" 6 : #include "envoy/runtime/runtime.h" 7 : #include "envoy/server/factory_context.h" 8 : #include "envoy/upstream/health_checker.h" 9 : 10 : namespace Envoy { 11 : namespace Server { 12 : namespace Configuration { 13 : 14 : class HealthCheckerFactoryContext { 15 : public: 16 0 : virtual ~HealthCheckerFactoryContext() = default; 17 : 18 : /** 19 : * @return Upstream::Cluster& the owning cluster. 20 : */ 21 : virtual Upstream::Cluster& cluster() PURE; 22 : 23 : /** 24 : * @return Runtime::Loader& the singleton runtime loader for the server. 25 : */ 26 : virtual Envoy::Runtime::Loader& runtime() PURE; 27 : 28 : /** 29 : * @return Event::Dispatcher& the main thread's dispatcher. This dispatcher should be used 30 : * for all singleton processing. 31 : */ 32 : virtual Event::Dispatcher& mainThreadDispatcher() PURE; 33 : 34 : /* 35 : * @return Upstream::HealthCheckEventLoggerPtr the health check event logger for the 36 : * created health checkers. This function may not be idempotent. 37 : */ 38 : virtual Upstream::HealthCheckEventLoggerPtr eventLogger() PURE; 39 : 40 : /** 41 : * @return ProtobufMessage::ValidationVisitor& validation visitor for health checker configuration 42 : * messages. 43 : */ 44 : virtual ProtobufMessage::ValidationVisitor& messageValidationVisitor() PURE; 45 : 46 : /** 47 : * @return Api::Api& the API used by the server. 48 : */ 49 : virtual Api::Api& api() PURE; 50 : 51 : /** 52 : * @return AccessLogManager for use by the entire server. 53 : */ 54 : virtual AccessLog::AccessLogManager& accessLogManager() PURE; 55 : 56 : /* 57 : * @return Server context. 58 : */ 59 : virtual Server::Configuration::ServerFactoryContext& serverFactoryContext() PURE; 60 : 61 : /** 62 : * Set the event logger to the context, nullptr is accepted since 63 : * the default in the context is nullptr. 64 : * @param event_logger the health check event logger. 65 : */ 66 : virtual void setEventLogger(Upstream::HealthCheckEventLoggerPtr event_logger) PURE; 67 : }; 68 : 69 : /** 70 : * Implemented by each custom health checker and registered via Registry::registerFactory() 71 : * or the convenience class RegisterFactory. 72 : */ 73 : class CustomHealthCheckerFactory : public Config::TypedFactory { 74 : public: 75 0 : ~CustomHealthCheckerFactory() override = default; 76 : 77 : /** 78 : * Creates a particular custom health checker factory implementation. 79 : * 80 : * @param config supplies the configuration as a full envoy::config::core::v3::HealthCheck 81 : * config. The implementation of this method can get the specific configuration for a custom 82 : * health check from custom_health_check().config(). 83 : * @param context supplies the custom health checker's context. 84 : * @return HealthCheckerSharedPtr the pointer of a health checker instance. 85 : */ 86 : virtual Upstream::HealthCheckerSharedPtr 87 : createCustomHealthChecker(const envoy::config::core::v3::HealthCheck& config, 88 : HealthCheckerFactoryContext& context) PURE; 89 : 90 60 : std::string category() const override { return "envoy.health_checkers"; } 91 : }; 92 : 93 : } // namespace Configuration 94 : } // namespace Server 95 : } // namespace Envoy