Skip to content

Commit

Permalink
Allocate response buffer. (envoyproxy#20)
Browse files Browse the repository at this point in the history
* Allocate response buffer.

* lint format.
  • Loading branch information
qiwzhang committed Jan 27, 2017
1 parent c457241 commit 73376d5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions mixerclient/src/client_impl.cc
Expand Up @@ -18,6 +18,7 @@
using ::istio::mixer::v1::CheckResponse;
using ::istio::mixer::v1::ReportResponse;
using ::istio::mixer::v1::QuotaResponse;
using ::google::protobuf::util::Status;

namespace istio {
namespace mixer_client {
Expand All @@ -38,18 +39,30 @@ MixerClientImpl::MixerClientImpl(const MixerClientOptions &options)
MixerClientImpl::~MixerClientImpl() {}

void MixerClientImpl::Check(const Attributes &attributes, DoneFunc on_done) {
CheckResponse response;
check_transport_->Send(attributes, &response, on_done);
auto response = new CheckResponse;
check_transport_->Send(attributes, response,
[response, on_done](const Status &status) {
delete response;
on_done(status);
});
}

void MixerClientImpl::Report(const Attributes &attributes, DoneFunc on_done) {
ReportResponse response;
report_transport_->Send(attributes, &response, on_done);
auto response = new ReportResponse;
report_transport_->Send(attributes, response,
[response, on_done](const Status &status) {
delete response;
on_done(status);
});
}

void MixerClientImpl::Quota(const Attributes &attributes, DoneFunc on_done) {
QuotaResponse response;
quota_transport_->Send(attributes, &response, on_done);
auto response = new QuotaResponse;
quota_transport_->Send(attributes, response,
[response, on_done](const Status &status) {
delete response;
on_done(status);
});
}

// Creates a MixerClient object.
Expand Down

0 comments on commit 73376d5

Please sign in to comment.