Skip to content

Commit a2009dd

Browse files
authored
Update to mixer client with report batch (istio#357)
1 parent b33e781 commit a2009dd

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

src/envoy/mixer/grpc_transport.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ class CheckGrpcTransport : public GrpcTransport {
8484
void Call(const ::istio::mixer::v1::CheckRequest& request,
8585
::istio::mixer::v1::CheckResponse* response,
8686
::istio::mixer_client::DoneFunc on_done) {
87-
on_done_ = on_done;
87+
on_done_ = [this, response,
88+
on_done](const ::google::protobuf::util::Status& status) {
89+
if (status.ok()) {
90+
log().debug("Check response: {}", response->DebugString());
91+
}
92+
on_done(status);
93+
};
8894
log().debug("Call grpc check: {}", request.DebugString());
8995
stub_.Check(nullptr, &request, response, nullptr);
9096
}
@@ -128,7 +134,13 @@ class QuotaGrpcTransport : public GrpcTransport {
128134
void Call(const ::istio::mixer::v1::QuotaRequest& request,
129135
::istio::mixer::v1::QuotaResponse* response,
130136
::istio::mixer_client::DoneFunc on_done) {
131-
on_done_ = on_done;
137+
on_done_ = [this, response,
138+
on_done](const ::google::protobuf::util::Status& status) {
139+
if (status.ok()) {
140+
log().debug("Quota response: {}", response->DebugString());
141+
}
142+
on_done(status);
143+
};
132144
log().debug("Call grpc quota: {}", request.DebugString());
133145
stub_.Quota(nullptr, &request, response, nullptr);
134146
}

src/envoy/mixer/http_control.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ using ::istio::mixer_client::Attributes;
3030
using ::istio::mixer_client::CheckOptions;
3131
using ::istio::mixer_client::DoneFunc;
3232
using ::istio::mixer_client::MixerClientOptions;
33+
using ::istio::mixer_client::ReportOptions;
3334
using ::istio::mixer_client::QuotaOptions;
3435

3536
namespace Envoy {
@@ -182,7 +183,7 @@ HttpControl::HttpControl(const MixerConfig& mixer_config,
182183
Upstream::ClusterManager& cm)
183184
: mixer_config_(mixer_config) {
184185
if (GrpcTransport::IsMixerServerConfigured(cm)) {
185-
MixerClientOptions options(GetCheckOptions(mixer_config),
186+
MixerClientOptions options(GetCheckOptions(mixer_config), ReportOptions(),
186187
GetQuotaOptions(mixer_config));
187188
auto cms = std::make_shared<ClusterManagerStore>(cm);
188189
options.check_transport = CheckGrpcTransport::GetFunc(cms);
@@ -262,10 +263,8 @@ void HttpControl::Quota(HttpRequestDataPtr request_data, DoneFunc on_done) {
262263
void HttpControl::Report(HttpRequestDataPtr request_data,
263264
const HeaderMap* response_headers,
264265
const AccessLog::RequestInfo& request_info,
265-
int check_status, DoneFunc on_done) {
266+
int check_status) {
266267
if (!mixer_client_) {
267-
on_done(
268-
Status(StatusCode::INVALID_ARGUMENT, "Missing mixer_server cluster"));
269268
return;
270269
}
271270

@@ -276,7 +275,7 @@ void HttpControl::Report(HttpRequestDataPtr request_data,
276275
FillRequestInfoAttributes(request_info, check_status,
277276
&request_data->attributes);
278277
log().debug("Send Report: {}", request_data->attributes.DebugString());
279-
mixer_client_->Report(request_data->attributes, on_done);
278+
mixer_client_->Report(request_data->attributes);
280279
}
281280

282281
} // namespace Mixer

src/envoy/mixer/http_control.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class HttpControl final : public Logger::Loggable<Logger::Id::http> {
5252
// Make mixer report call.
5353
void Report(HttpRequestDataPtr request_data,
5454
const HeaderMap* response_headers,
55-
const AccessLog::RequestInfo& request_info, int check_status_code,
56-
::istio::mixer_client::DoneFunc on_done);
55+
const AccessLog::RequestInfo& request_info,
56+
int check_status_code);
5757

5858
private:
5959
void FillCheckAttributes(HeaderMap& header_map,

src/envoy/mixer/http_filter.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,8 @@ class Instance : public Http::StreamDecoderFilter,
296296
if (!request_data_) return;
297297
// Make sure not to use any class members at the callback.
298298
// The class may be gone when it is called.
299-
// Log() is a static function so it is OK.
300299
http_control_->Report(request_data_, response_headers, request_info,
301-
check_status_code_, [](const Status& status) {
302-
Log().debug("Report returns status: {}",
303-
status.ToString());
304-
});
300+
check_status_code_);
305301
}
306302

307303
static spdlog::logger& Log() {

src/envoy/mixer/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
################################################################################
1616
#
1717

18-
MIXER_CLIENT = "df656b9fc7964043be53d5afee4f32cf71e7fd28"
18+
MIXER_CLIENT = "6080a5318230c61f03c5e5d03288e5ee67ae4952"
1919

2020
def mixer_client_repositories(bind=True):
2121
native.git_repository(

0 commit comments

Comments
 (0)