Skip to content

Commit

Permalink
Merge unary mixer api (envoyproxy#70)
Browse files Browse the repository at this point in the history
* use unary api.

* fix attribute_converter_test

* fixed utils/protobuf.h

* add check cache.

* Added quota cache.

* Remove grpc dependency.

* fix format

* update to latest api.
  • Loading branch information
qiwzhang authored Jun 1, 2017
1 parent 8035b35 commit 5ed8205
Show file tree
Hide file tree
Showing 31 changed files with 554 additions and 2,222 deletions.
76 changes: 12 additions & 64 deletions mixerclient/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,18 @@ cc_library(
name = "mixer_client_lib",
srcs = [
"src/attribute.cc",
"src/attribute_context.cc",
"src/attribute_context.h",
"src/attribute_converter.cc",
"src/attribute_converter.h",
"src/cache_key_set.cc",
"src/cache_key_set.h",
"src/check_cache.cc",
"src/check_cache.h",
"src/cache_key_set.cc",
"src/cache_key_set.h",
"src/client_impl.cc",
"src/client_impl.h",
"src/context_update.cc",
"src/context_update.h",
"src/grpc_transport.cc",
"src/grpc_transport.h",
"src/quota_cache.cc",
"src/quota_cache.h",
"src/signature.cc",
"src/signature.h",
"src/stream_transport.h",
"src/transport.h",
"src/quota_cache.cc",
"src/quota_cache.h",
"utils/md5.cc",
"utils/md5.h",
"utils/protobuf.cc",
Expand All @@ -49,15 +42,13 @@ cc_library(
"include/attribute.h",
"include/client.h",
"include/options.h",
"include/transport.h",
],
visibility = ["//visibility:public"],
deps = [
":simple_lru_cache",
"//prefetch:quota_prefetch_lib",
"//external:boringssl_crypto",
"//external:grpc++",
"//external:mixer_api_cc_proto",
"//prefetch:quota_prefetch_lib",
],
)

Expand Down Expand Up @@ -98,31 +89,9 @@ cc_test(
)

cc_test(
name = "attribute_context_test",
name = "attribute_converter_test",
size = "small",
srcs = ["src/attribute_context_test.cc"],
linkstatic = 1,
deps = [
":mixer_client_lib",
"//external:googletest_main",
],
)

cc_test(
name = "context_update_test",
size = "small",
srcs = ["src/context_update_test.cc"],
linkstatic = 1,
deps = [
":mixer_client_lib",
"//external:googletest_main",
],
)

cc_test(
name = "md5_test",
size = "small",
srcs = ["utils/md5_test.cc"],
srcs = ["src/attribute_converter_test.cc"],
linkstatic = 1,
deps = [
":mixer_client_lib",
Expand All @@ -141,17 +110,6 @@ cc_test(
],
)

cc_test(
name = "signature_test",
size = "small",
srcs = ["src/signature_test.cc"],
linkstatic = 1,
deps = [
":mixer_client_lib",
"//external:googletest_main",
],
)

cc_test(
name = "check_cache_test",
size = "small",
Expand All @@ -175,14 +133,9 @@ cc_test(
)

cc_test(
name = "grpc_transport_test",
name = "md5_test",
size = "small",
srcs = ["src/grpc_transport_test.cc"],
linkopts = [
"-lm",
"-lpthread",
"-lrt",
],
srcs = ["utils/md5_test.cc"],
linkstatic = 1,
deps = [
":mixer_client_lib",
Expand All @@ -191,14 +144,9 @@ cc_test(
)

cc_test(
name = "stream_transport_test",
name = "signature_test",
size = "small",
srcs = ["src/stream_transport_test.cc"],
linkopts = [
"-lm",
"-lpthread",
"-lrt",
],
srcs = ["src/signature_test.cc"],
linkstatic = 1,
deps = [
":mixer_client_lib",
Expand Down
2 changes: 0 additions & 2 deletions mixerclient/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ load(
"protobuf_repositories",
"googletest_repositories",
"googleapis_repositories",
"grpc_repositories",
"mixerapi_repositories",
)

boringssl_repositories()
protobuf_repositories()
googletest_repositories()
googleapis_repositories()
grpc_repositories()
mixerapi_repositories()

33 changes: 23 additions & 10 deletions mixerclient/include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,52 @@

#include "attribute.h"
#include "google/protobuf/stubs/status.h"
#include "mixer/v1/service.pb.h"
#include "options.h"
#include "transport.h"

namespace istio {
namespace mixer_client {

// Defines a function prototype used when an asynchronous transport call
// is completed.
// Uses UNAVAILABLE status code to indicate network failure.
using DoneFunc = std::function<void(const ::google::protobuf::util::Status&)>;

// Defines a function prototype to make an asynchronous Check call
using TransportCheckFunc = std::function<void(
const ::istio::mixer::v1::CheckRequest& request,
::istio::mixer::v1::CheckResponse* response, DoneFunc on_done)>;

// Defines a function prototype to make an asynchronous Report call
using TransportReportFunc = std::function<void(
const ::istio::mixer::v1::ReportRequest& request,
::istio::mixer::v1::ReportResponse* response, DoneFunc on_done)>;

// Defines a function prototype to make an asynchronous Quota call
using TransportQuotaFunc = std::function<void(
const ::istio::mixer::v1::QuotaRequest& request,
::istio::mixer::v1::QuotaResponse* response, DoneFunc on_done)>;

// Defines the options to create an instance of MixerClient interface.
struct MixerClientOptions {
// Default constructor with default values.
MixerClientOptions() : transport(nullptr) {}
MixerClientOptions() {}

// Constructor with specified option values.
MixerClientOptions(const CheckOptions& check_options,
const QuotaOptions& quota_options)
: check_options(check_options),
quota_options(quota_options),
transport(nullptr) {}
: check_options(check_options), quota_options(quota_options) {}

// Check options.
CheckOptions check_options;

// Quota options.
QuotaOptions quota_options;

// gRPC mixer server address.
std::string mixer_server;

// A custom transport object.
TransportInterface* transport;
// Transport functions.
TransportCheckFunc check_transport;
TransportReportFunc report_transport;
TransportQuotaFunc quota_transport;
};

class MixerClient {
Expand Down
84 changes: 0 additions & 84 deletions mixerclient/include/transport.h

This file was deleted.

Loading

0 comments on commit 5ed8205

Please sign in to comment.