Line data Source code
1 : #pragma once 2 : 3 : #include "source/common/network/connection_impl.h" 4 : #include "source/server/config_validation/dispatcher.h" 5 : 6 : namespace Envoy { 7 : namespace Network { 8 : 9 : /* 10 : Class representing connection to upstream entity in config verification mode. The connection is 11 : not really established, but sockets may be allocated. Methods doing "real" connections should be 12 : overridden with no-op implementations. 13 : */ 14 : class ConfigValidateConnection : public Network::ClientConnectionImpl { 15 : public: 16 : ConfigValidateConnection(Event::ValidationDispatcher& dispatcher, 17 : Network::Address::InstanceConstSharedPtr remote_address, 18 : Network::Address::InstanceConstSharedPtr source_address, 19 : Network::TransportSocketPtr&& transport_socket, 20 : const Network::ConnectionSocket::OptionsSharedPtr& options, 21 : const Network::TransportSocketOptionsConstSharedPtr& transport_options) 22 : : Network::ClientConnectionImpl(dispatcher, remote_address, source_address, 23 0 : std::move(transport_socket), options, transport_options) {} 24 : 25 : // Unit tests may instantiate it without proper event machine and leave opened sockets. 26 : // Do some cleanup before invoking base class's destructor. 27 0 : ~ConfigValidateConnection() override { close(ConnectionCloseType::NoFlush); } 28 : 29 : // connect may be called in config verification mode. 30 : // It is redefined as no-op. Calling parent's method triggers connection to upstream host. 31 0 : void connect() override {} 32 : }; 33 : 34 : } // namespace Network 35 : } // namespace Envoy