Skip to content

Commit

Permalink
Add sourceService. (envoyproxy#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiwzhang authored Feb 9, 2017
1 parent 6e372fc commit 28105ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/envoy/mixer/http_control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace Mixer {
namespace {

const std::string kProxyPeerID = "Istio/Proxy";
const std::string kEnvNameTargetService = "TARGET_SERVICE";

// Define lower case string for X-Forwarded-Host.
const LowerCaseString kHeaderNameXFH("x-forwarded-host", false);
Expand All @@ -44,6 +43,11 @@ const std::string kAttrNameLogMessage = "logMessage";
const std::string kAttrNameResponseTime = "responseTime";
const std::string kAttrNameOriginIp = "originIp";
const std::string kAttrNameOriginHost = "originHost";

const std::string kEnvNameSourceService = "SOURCE_SERVICE";
const std::string kEnvNameTargetService = "TARGET_SERVICE";

const std::string kAttrNameSourceService = "sourceService";
const std::string kAttrNameTargetService = "targetService";

Attributes::Value StringValue(const std::string& str) {
Expand Down Expand Up @@ -147,6 +151,10 @@ HttpControl::HttpControl(const std::string& mixer_server) {
options.mixer_server = mixer_server;
mixer_client_ = ::istio::mixer_client::CreateMixerClient(options);

auto source_service = getenv(kEnvNameSourceService.c_str());
if (source_service) {
source_service_ = source_service;
}
auto target_service = getenv(kEnvNameTargetService.c_str());
if (target_service) {
target_service_ = target_service;
Expand All @@ -157,6 +165,7 @@ void HttpControl::FillCheckAttributes(const HeaderMap& header_map,
Attributes* attr) {
FillRequestHeaderAttributes(header_map, attr);

SetStringAttribute(kAttrNameSourceService, source_service_, attr);
SetStringAttribute(kAttrNameTargetService, target_service_, attr);
attr->attributes[kAttrNamePeerId] = StringValue(kProxyPeerID);
}
Expand Down
2 changes: 2 additions & 0 deletions src/envoy/mixer/http_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class HttpControl final : public Logger::Loggable<Logger::Id::http> {

// The mixer client
std::unique_ptr<::istio::mixer_client::MixerClient> mixer_client_;
// Source service
std::string source_service_;
// Target service
std::string target_service_;
};
Expand Down

0 comments on commit 28105ca

Please sign in to comment.