Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/http/api_listener.h" 4 : 5 : namespace Envoy { 6 : namespace Server { 7 : 8 : /** 9 : * Listener that allows consumer to interact with Envoy via a designated API. 10 : */ 11 : class ApiListener { 12 : public: 13 : enum class Type { HttpApiListener }; 14 : 15 1 : virtual ~ApiListener() = default; 16 : 17 : /** 18 : * An ApiListener is uniquely identified by its name. 19 : * 20 : * @return the name of the ApiListener. 21 : */ 22 : virtual absl::string_view name() const PURE; 23 : 24 : /** 25 : * @return the Type of the ApiListener. 26 : */ 27 : virtual Type type() const PURE; 28 : 29 : /** 30 : * Create an Http::ApiListener capable of starting synthetic HTTP streams. The returned listener 31 : * must only be deleted in the dispatcher's thread. 32 : * 33 : * While Envoy Mobile only uses this from the main thread, taking a dispatcher as a parameter 34 : * allows other users to use this from worker threads as well. 35 : * 36 : * @return valid pointer IFF type() == Type::HttpApiListener, otherwise nullptr. 37 : */ 38 : virtual Http::ApiListenerPtr createHttpApiListener(Event::Dispatcher& dispatcher) PURE; 39 : }; 40 : 41 : using ApiListenerPtr = std::unique_ptr<ApiListener>; 42 : using ApiListenerOptRef = absl::optional<std::reference_wrapper<ApiListener>>; 43 : 44 : } // namespace Server 45 : } // namespace Envoy