Lines
100 %
Functions
#pragma once
#include <chrono>
#include <string>
#include "envoy/router/shadow_writer.h"
#include "envoy/upstream/cluster_manager.h"
namespace Envoy {
namespace Router {
/**
* Implementation of ShadowWriter that takes incoming requests to shadow and implements "fire and
* forget" behavior using an async client.
*/
class ShadowWriterImpl : Logger::Loggable<Logger::Id::router>,
public ShadowWriter,
public Http::AsyncClient::Callbacks {
public:
ShadowWriterImpl(Upstream::ClusterManager& cm) : cm_(cm) {}
// Router::ShadowWriter
void shadow(const std::string& cluster, Http::RequestMessagePtr&& request,
const Http::AsyncClient::RequestOptions& options) override;
Http::AsyncClient::OngoingRequest*
streamingShadow(const std::string& cluster, Http::RequestHeaderMapPtr&& headers,
// Http::AsyncClient::Callbacks
void onSuccess(const Http::AsyncClient::Request&, Http::ResponseMessagePtr&&) override {}
void onFailure(const Http::AsyncClient::Request&, Http::AsyncClient::FailureReason) override {}
void onBeforeFinalizeUpstreamSpan(Envoy::Tracing::Span&,
const Http::ResponseHeaderMap*) override {}
private:
Upstream::ThreadLocalCluster*
getClusterAndPreprocessHeadersAndOptions(absl::string_view cluster,
Http::RequestHeaderMap& headers,
const Http::AsyncClient::RequestOptions& options);
Upstream::ClusterManager& cm_;
};
} // namespace Router
} // namespace Envoy