Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/endpoints/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def servicecontrol_client_repositories(bind=True):

native.git_repository(
name = "servicecontrol_client_git",
commit = "069bc7156d92a2d84929309d69610c76f6b8dab9",
commit = "c815b890f6ac60e9dc57f80c97b1bccc9930c073",
remote = "https://github.com/cloudendpoints/service-control-client-cxx.git",
)

Expand Down
30 changes: 11 additions & 19 deletions contrib/endpoints/src/api_manager/service_control/aggregated.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ using ::google::api_manager::utils::Status;
using ::google::protobuf::util::error::Code;

using ::google::service_control_client::CheckAggregationOptions;
// TODO(jaebong) enable this after service_control_client library is updated
// using ::google::service_control_client::QuotaAggregationOptions;
using ::google::service_control_client::QuotaAggregationOptions;
using ::google::service_control_client::ReportAggregationOptions;
using ::google::service_control_client::ServiceControlClient;
using ::google::service_control_client::ServiceControlClientOptions;
Expand Down Expand Up @@ -98,9 +97,6 @@ CheckAggregationOptions GetCheckAggregationOptions(
kCheckAggregationExpirationMs);
}

// TODO(jaebong) enable this after service_control_client library is updated
/*
// TODO(jaebong): - need to add quota configuration
// Generate QuotaAggregationOptions
QuotaAggregationOptions GetQuotaAggregationOptions(
const ServerConfig* server_config) {
Expand All @@ -118,7 +114,6 @@ QuotaAggregationOptions GetQuotaAggregationOptions(

return option;
}
*/

// Generates ReportAggregationOptions.
ReportAggregationOptions GetReportAggregationOptions(
Expand Down Expand Up @@ -209,9 +204,7 @@ Status Aggregated::Init() {
// env->StartPeriodicTimer doens't work at constructor.
ServiceControlClientOptions options(
GetCheckAggregationOptions(server_config_),
// TODO(jaebong) enable this after service_control_client library is
// updated
// GetQuotaAggregationOptions(server_config_),
GetQuotaAggregationOptions(server_config_),
GetReportAggregationOptions(server_config_));

std::stringstream ss;
Expand All @@ -228,13 +221,9 @@ Status Aggregated::Init() {
const CheckRequest& request, CheckResponse* response,
TransportDoneFunc on_done) { Call(request, response, on_done, nullptr); };

/*
// TODO(jaebong) enable this after service_control_client library is updated
options.quota_transport = [this](
const AllocateQuotaRequest& request, AllocateQuotaResponse* response,
TransportDoneFunc on_done) { Call(request, response, on_done, nullptr);
};
*/
options.quota_transport = [this](
const AllocateQuotaRequest& request, AllocateQuotaResponse* response,
TransportDoneFunc on_done) { Call(request, response, on_done, nullptr); };

options.report_transport = [this](
const ReportRequest& request, ReportResponse* response,
Expand Down Expand Up @@ -412,9 +401,12 @@ void Aggregated::Quota(const QuotaRequestInfo& info,
delete response;
};

// TODO(jaebong) Temporarily call Chemist directly instead of using service
// control client library
Call(*request, response, quota_on_done, trace_span.get());
client_->Quota(*request, response, quota_on_done,
[trace_span, this](const AllocateQuotaRequest& request,
AllocateQuotaResponse* response,
TransportDoneFunc on_done) {
Call(request, response, on_done, trace_span.get());
});

// There is no reference to request anymore at this point and it is safe to
// free request now.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ using ::google::api_manager::utils::Status;
using ::google::protobuf::util::error::Code;
using ::google::service_control_client::ServiceControlClient;
using ::google::service_control_client::TransportCheckFunc;
using ::google::service_control_client::TransportQuotaFunc;
using ::google::service_control_client::TransportReportFunc;
using ::testing::Return;
using ::testing::Invoke;
Expand Down Expand Up @@ -89,6 +90,15 @@ class MockServiceControClient : public ServiceControlClient {
CheckResponse*));
MOCK_METHOD4(Check, void(const CheckRequest&, CheckResponse*, DoneCallback,
TransportCheckFunc));

MOCK_METHOD2(Quota,
::google::protobuf::util::Status(const AllocateQuotaRequest&,
AllocateQuotaResponse*));
MOCK_METHOD3(Quota, void(const AllocateQuotaRequest&, AllocateQuotaResponse*,
DoneCallback));
MOCK_METHOD4(Quota, void(const AllocateQuotaRequest&, AllocateQuotaResponse*,
DoneCallback, TransportQuotaFunc));

MOCK_METHOD3(Report,
void(const ReportRequest&, ReportResponse*, DoneCallback));
MOCK_METHOD2(Report, ::google::protobuf::util::Status(const ReportRequest&,
Expand Down
1 change: 0 additions & 1 deletion contrib/endpoints/src/api_manager/service_control/proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,6 @@ utils::Status Proto::FillAllocateQuotaRequest(
std::string(info.api_key));
}

// TODO(jaebong) - Read from service conf?
// allocate_operation.quota_mode
operation->set_quota_mode(
::google::api::servicecontrol::v1::QuotaOperation_QuotaMode::
Expand Down