Line data Source code
1 : #pragma once 2 : 3 : #include <chrono> 4 : #include <string> 5 : 6 : #include "envoy/router/shadow_writer.h" 7 : #include "envoy/upstream/cluster_manager.h" 8 : 9 : namespace Envoy { 10 : namespace Router { 11 : 12 : /** 13 : * Implementation of ShadowWriter that takes incoming requests to shadow and implements "fire and 14 : * forget" behavior using an async client. 15 : */ 16 : class ShadowWriterImpl : Logger::Loggable<Logger::Id::router>, 17 : public ShadowWriter, 18 : public Http::AsyncClient::Callbacks { 19 : public: 20 175 : ShadowWriterImpl(Upstream::ClusterManager& cm) : cm_(cm) {} 21 : 22 : // Router::ShadowWriter 23 : void shadow(const std::string& cluster, Http::RequestMessagePtr&& request, 24 : const Http::AsyncClient::RequestOptions& options) override; 25 : 26 : Http::AsyncClient::OngoingRequest* 27 : streamingShadow(const std::string& cluster, Http::RequestHeaderMapPtr&& headers, 28 : const Http::AsyncClient::RequestOptions& options) override; 29 : 30 : // Http::AsyncClient::Callbacks 31 0 : void onSuccess(const Http::AsyncClient::Request&, Http::ResponseMessagePtr&&) override {} 32 0 : void onFailure(const Http::AsyncClient::Request&, Http::AsyncClient::FailureReason) override {} 33 : void onBeforeFinalizeUpstreamSpan(Envoy::Tracing::Span&, 34 0 : const Http::ResponseHeaderMap*) override {} 35 : 36 : private: 37 : Upstream::ThreadLocalCluster* 38 : getClusterAndPreprocessHeadersAndOptions(absl::string_view cluster, 39 : Http::RequestHeaderMap& headers, 40 : const Http::AsyncClient::RequestOptions& options); 41 : Upstream::ClusterManager& cm_; 42 : }; 43 : 44 : } // namespace Router 45 : } // namespace Envoy