Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : #include <string> 5 : 6 : #include "envoy/common/pure.h" 7 : #include "envoy/network/address.h" 8 : 9 : #include "source/common/network/io_socket_handle_impl.h" 10 : 11 : namespace Envoy { 12 : namespace Extensions { 13 : namespace Tracers { 14 : namespace XRay { 15 : 16 : /** 17 : * The broker is a way to isolate the network dependency required to communicate with the X-Ray 18 : * daemon. 19 : */ 20 : class DaemonBroker { 21 : public: 22 : /** 23 : * Sends the input string as data to the X-Ray daemon. 24 : * The input string is typically a JSON serialized Span. 25 : * This method prefixes the data with a header necessary for the daemon to accept the input. 26 : */ 27 : virtual void send(const std::string& data) const PURE; 28 : 29 0 : virtual ~DaemonBroker() = default; 30 : }; 31 : 32 : using DaemonBrokerPtr = std::unique_ptr<DaemonBroker>; 33 : 34 : class DaemonBrokerImpl : public DaemonBroker { 35 : public: 36 : /** 37 : * Creates a new Broker instance. 38 : * 39 : * @param daemon_endpoint The ip and port on which the X-Ray daemon is listening. 40 : */ 41 : explicit DaemonBrokerImpl(const std::string& daemon_endpoint); 42 : 43 : void send(const std::string& data) const final; 44 : 45 : private: 46 : const Network::Address::InstanceConstSharedPtr address_; 47 : const Network::IoHandlePtr io_handle_; 48 : }; 49 : 50 : } // namespace XRay 51 : } // namespace Tracers 52 : } // namespace Extensions 53 : } // namespace Envoy