Skip to content

Commit 5ed8205

Browse files
authored
Merge unary mixer api (istio#70)
* 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.
1 parent 8035b35 commit 5ed8205

31 files changed

+554
-2222
lines changed

mixerclient/BUILD

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,18 @@ cc_library(
2020
name = "mixer_client_lib",
2121
srcs = [
2222
"src/attribute.cc",
23-
"src/attribute_context.cc",
24-
"src/attribute_context.h",
23+
"src/attribute_converter.cc",
2524
"src/attribute_converter.h",
26-
"src/cache_key_set.cc",
27-
"src/cache_key_set.h",
2825
"src/check_cache.cc",
2926
"src/check_cache.h",
27+
"src/cache_key_set.cc",
28+
"src/cache_key_set.h",
3029
"src/client_impl.cc",
3130
"src/client_impl.h",
32-
"src/context_update.cc",
33-
"src/context_update.h",
34-
"src/grpc_transport.cc",
35-
"src/grpc_transport.h",
36-
"src/quota_cache.cc",
37-
"src/quota_cache.h",
3831
"src/signature.cc",
3932
"src/signature.h",
40-
"src/stream_transport.h",
41-
"src/transport.h",
33+
"src/quota_cache.cc",
34+
"src/quota_cache.h",
4235
"utils/md5.cc",
4336
"utils/md5.h",
4437
"utils/protobuf.cc",
@@ -49,15 +42,13 @@ cc_library(
4942
"include/attribute.h",
5043
"include/client.h",
5144
"include/options.h",
52-
"include/transport.h",
5345
],
5446
visibility = ["//visibility:public"],
5547
deps = [
5648
":simple_lru_cache",
49+
"//prefetch:quota_prefetch_lib",
5750
"//external:boringssl_crypto",
58-
"//external:grpc++",
5951
"//external:mixer_api_cc_proto",
60-
"//prefetch:quota_prefetch_lib",
6152
],
6253
)
6354

@@ -98,31 +89,9 @@ cc_test(
9889
)
9990

10091
cc_test(
101-
name = "attribute_context_test",
92+
name = "attribute_converter_test",
10293
size = "small",
103-
srcs = ["src/attribute_context_test.cc"],
104-
linkstatic = 1,
105-
deps = [
106-
":mixer_client_lib",
107-
"//external:googletest_main",
108-
],
109-
)
110-
111-
cc_test(
112-
name = "context_update_test",
113-
size = "small",
114-
srcs = ["src/context_update_test.cc"],
115-
linkstatic = 1,
116-
deps = [
117-
":mixer_client_lib",
118-
"//external:googletest_main",
119-
],
120-
)
121-
122-
cc_test(
123-
name = "md5_test",
124-
size = "small",
125-
srcs = ["utils/md5_test.cc"],
94+
srcs = ["src/attribute_converter_test.cc"],
12695
linkstatic = 1,
12796
deps = [
12897
":mixer_client_lib",
@@ -141,17 +110,6 @@ cc_test(
141110
],
142111
)
143112

144-
cc_test(
145-
name = "signature_test",
146-
size = "small",
147-
srcs = ["src/signature_test.cc"],
148-
linkstatic = 1,
149-
deps = [
150-
":mixer_client_lib",
151-
"//external:googletest_main",
152-
],
153-
)
154-
155113
cc_test(
156114
name = "check_cache_test",
157115
size = "small",
@@ -175,14 +133,9 @@ cc_test(
175133
)
176134

177135
cc_test(
178-
name = "grpc_transport_test",
136+
name = "md5_test",
179137
size = "small",
180-
srcs = ["src/grpc_transport_test.cc"],
181-
linkopts = [
182-
"-lm",
183-
"-lpthread",
184-
"-lrt",
185-
],
138+
srcs = ["utils/md5_test.cc"],
186139
linkstatic = 1,
187140
deps = [
188141
":mixer_client_lib",
@@ -191,14 +144,9 @@ cc_test(
191144
)
192145

193146
cc_test(
194-
name = "stream_transport_test",
147+
name = "signature_test",
195148
size = "small",
196-
srcs = ["src/stream_transport_test.cc"],
197-
linkopts = [
198-
"-lm",
199-
"-lpthread",
200-
"-lrt",
201-
],
149+
srcs = ["src/signature_test.cc"],
202150
linkstatic = 1,
203151
deps = [
204152
":mixer_client_lib",

mixerclient/WORKSPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ load(
2020
"protobuf_repositories",
2121
"googletest_repositories",
2222
"googleapis_repositories",
23-
"grpc_repositories",
2423
"mixerapi_repositories",
2524
)
2625

2726
boringssl_repositories()
2827
protobuf_repositories()
2928
googletest_repositories()
3029
googleapis_repositories()
31-
grpc_repositories()
3230
mixerapi_repositories()
3331

mixerclient/include/client.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,52 @@
1818

1919
#include "attribute.h"
2020
#include "google/protobuf/stubs/status.h"
21+
#include "mixer/v1/service.pb.h"
2122
#include "options.h"
22-
#include "transport.h"
2323

2424
namespace istio {
2525
namespace mixer_client {
2626

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

32+
// Defines a function prototype to make an asynchronous Check call
33+
using TransportCheckFunc = std::function<void(
34+
const ::istio::mixer::v1::CheckRequest& request,
35+
::istio::mixer::v1::CheckResponse* response, DoneFunc on_done)>;
36+
37+
// Defines a function prototype to make an asynchronous Report call
38+
using TransportReportFunc = std::function<void(
39+
const ::istio::mixer::v1::ReportRequest& request,
40+
::istio::mixer::v1::ReportResponse* response, DoneFunc on_done)>;
41+
42+
// Defines a function prototype to make an asynchronous Quota call
43+
using TransportQuotaFunc = std::function<void(
44+
const ::istio::mixer::v1::QuotaRequest& request,
45+
::istio::mixer::v1::QuotaResponse* response, DoneFunc on_done)>;
46+
3147
// Defines the options to create an instance of MixerClient interface.
3248
struct MixerClientOptions {
3349
// Default constructor with default values.
34-
MixerClientOptions() : transport(nullptr) {}
50+
MixerClientOptions() {}
3551

3652
// Constructor with specified option values.
3753
MixerClientOptions(const CheckOptions& check_options,
3854
const QuotaOptions& quota_options)
39-
: check_options(check_options),
40-
quota_options(quota_options),
41-
transport(nullptr) {}
55+
: check_options(check_options), quota_options(quota_options) {}
4256

4357
// Check options.
4458
CheckOptions check_options;
4559

4660
// Quota options.
4761
QuotaOptions quota_options;
4862

49-
// gRPC mixer server address.
50-
std::string mixer_server;
51-
52-
// A custom transport object.
53-
TransportInterface* transport;
63+
// Transport functions.
64+
TransportCheckFunc check_transport;
65+
TransportReportFunc report_transport;
66+
TransportQuotaFunc quota_transport;
5467
};
5568

5669
class MixerClient {

mixerclient/include/transport.h

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)