Skip to content

Commit 6819cc0

Browse files
committed
feat:合入最新的C++客户端代码
1 parent 5e35984 commit 6819cc0

File tree

509 files changed

+35688
-29913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

509 files changed

+35688
-29913
lines changed

.clang-format

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
Language: Cpp
22
BasedOnStyle: Google
3-
Standard: Cpp03
4-
IndentWidth: 2
5-
TabWidth: 2
6-
ContinuationIndentWidth: 4
7-
ColumnLimit: 100
8-
AccessModifierOffset: -2
9-
AlignConsecutiveAssignments: true
10-
UseTab: Never
3+
ColumnLimit: 120
4+
5+
# 自动识别代码中的指针对齐方式,如果希望强制统一,则可以改为 false
6+
DerivePointerAlignment: true
7+
8+
# 默认对齐到类型名
9+
PointerAlignment: Left
1110

1211
# Only sort headers in each include block
1312
SortIncludes: true
1413
IncludeBlocks: Preserve
1514

16-
ConstructorInitializerAllOnOneLineOrOnePerLine: false
15+
# 让 #if/#else/#endif 宏中的内容保持缩进,比如:
16+
# #if defined(WIN)
17+
# # include <windows.h>
18+
# #else
19+
# # include <curl.h>
20+
# #endif
21+
IndentPPDirectives: AfterHash
22+
23+
# 不特殊看待 foreach 宏
24+
ForEachMacros: ['']

BUILD

+82-99
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
2+
13
licenses(["notice"])
24

35
package(default_visibility = ["//visibility:private"])
46

5-
load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library")
6-
77
cc_library(
88
name = "murmurhash",
9-
srcs = glob([
10-
"third_party/murmurhash/src/MurmurHash3.cpp",
11-
]),
9+
srcs = ["third_party/murmurhash/src/MurmurHash3.cpp"],
1210
hdrs = glob([
1311
"third_party/murmurhash/src/**/*.h",
1412
]),
@@ -28,45 +26,29 @@ cc_library(
2826
includes = [
2927
"third_party/yaml-cpp/include",
3028
],
29+
linkstatic = 1,
3130
visibility = [
3231
"//visibility:private",
3332
],
34-
linkstatic = 1,
3533
)
3634

3735
cc_library(
3836
name = "nghttp2",
39-
srcs = glob([
40-
"third_party/nghttp2/lib/**/*.c",
41-
],
42-
exclude = ["third_party/nghttp2/lib/**/*_test.c"]),
37+
srcs = glob(
38+
[
39+
"third_party/nghttp2/lib/**/*.c",
40+
],
41+
exclude = ["third_party/nghttp2/lib/**/*_test.c"],
42+
),
4343
hdrs = glob([
4444
"third_party/nghttp2/lib/includes/**/*.h",
4545
"third_party/nghttp2/lib/**/*.h",
4646
]),
4747
includes = ["third_party/nghttp2/lib/includes"],
48+
linkstatic = 1,
4849
visibility = [
4950
"//visibility:private",
5051
],
51-
linkstatic = 1,
52-
)
53-
54-
cc_library(
55-
name = "re2",
56-
srcs = glob([
57-
"third_party/re2/re2/*.cc",
58-
"third_party/re2/**/*.h",
59-
"third_party/re2/util/hash.cc",
60-
"third_party/re2/util/logging.cc",
61-
"third_party/re2/util/rune.cc",
62-
"third_party/re2/util/stringprintf.cc",
63-
"third_party/re2/util/strutil.cc",
64-
"third_party/re2/util/valgrind.cc",
65-
]),
66-
hdrs = glob(["third_party/re2/**/*.h",]),
67-
includes = ["third_party/re2"],
68-
visibility = ["//visibility:private"],
69-
linkstatic = 1,
7052
)
7153

7254
cc_library(
@@ -78,54 +60,38 @@ cc_library(
7860
hdrs = glob([
7961
"include/**/*.h",
8062
]),
81-
deps = [
82-
":trpcapi_cc_trpc",
83-
":code_cc_proto",
84-
":yaml-cpp-polaris-internal",
85-
":nghttp2",
86-
":murmurhash",
87-
":re2",
88-
":ratelimit_proto_v2",
89-
],
9063
includes = [
9164
"include",
9265
"polaris",
9366
],
9467
visibility = [
9568
"//visibility:public",
9669
],
97-
copts = [
98-
"-DREVISION=\\\"trpc-cpp\\\"",
99-
],
100-
)
101-
102-
cc_library(
103-
name = "polaris_api_fork",
104-
srcs = glob([
105-
"polaris/**/*.cpp",
106-
"polaris/**/*.h",
107-
]),
108-
hdrs = glob([
109-
"include/**/*.h",
110-
]),
11170
deps = [
112-
":trpcapi_cc_trpc",
11371
":code_cc_proto",
114-
":yaml-cpp-polaris-internal",
115-
":nghttp2",
11672
":murmurhash",
117-
":re2",
73+
":nghttp2",
11874
":ratelimit_proto_v2",
75+
":trpc_proto",
76+
":trpcapi_cc_trpc",
77+
":yaml-cpp-polaris-internal",
78+
"@com_googlesource_code_re2//:re2",
11979
],
120-
includes = [
121-
"include",
122-
"polaris",
123-
],
80+
)
81+
82+
alias(
83+
name = "polaris_api_fork",
84+
actual = ":polaris_api",
12485
visibility = [
12586
"//visibility:public",
12687
],
127-
copts = [
128-
"-DREVISION=\\\"trpc-cpp\\\"", "-DPOLARIS_SUPPORT_FORK",
88+
)
89+
90+
alias(
91+
name = "polaris_api_trpc",
92+
actual = ":polaris_api",
93+
visibility = [
94+
"//visibility:public",
12995
],
13096
)
13197

@@ -134,114 +100,122 @@ cc_proto_library(
134100
srcs = [
135101
"polaris/proto/v1/trpcapi.proto",
136102
],
103+
include = "polaris/proto",
104+
use_grpc_plugin = False,
137105
deps = [
138-
":service_proto",
139-
":routing_proto",
140106
":ratelimit_proto",
141107
":request_proto",
142108
":response_proto",
109+
":routing_proto",
110+
":service_proto",
143111
],
144-
include = "polaris/proto",
145-
use_grpc_plugin = False,
146112
)
147113

148114
cc_proto_library(
149115
name = "response_proto",
150116
srcs = ["polaris/proto/v1/response.proto"],
117+
include = "polaris/proto",
151118
deps = [
152-
":service_proto",
153-
":routing_proto",
154-
":ratelimit_proto",
155-
":client_proto",
156119
":circuit_breaker_proto",
120+
":client_proto",
121+
":dynamicweight_proto",
157122
":metric_proto",
158-
"@com_google_protobuf//:cc_wkt_protos"
123+
":ratelimit_proto",
124+
":routing_proto",
125+
":service_proto",
126+
"@com_google_protobuf//:cc_wkt_protos",
159127
],
160-
include = "polaris/proto",
161128
)
162129

163130
cc_proto_library(
164131
name = "client_proto",
165132
srcs = [":polaris/proto/v1/client.proto"],
133+
include = "polaris/proto",
166134
deps = [
167135
":model_proto",
168-
"@com_google_protobuf//:cc_wkt_protos"
136+
"@com_google_protobuf//:cc_wkt_protos",
169137
],
170-
include = "polaris/proto",
171138
)
172139

173140
cc_proto_library(
174141
name = "routing_proto",
175142
srcs = ["polaris/proto/v1/routing.proto"],
143+
include = "polaris/proto",
176144
deps = [
177145
":model_proto",
178-
"@com_google_protobuf//:cc_wkt_protos"
146+
"@com_google_protobuf//:cc_wkt_protos",
179147
],
180-
include = "polaris/proto",
181148
)
182149

183150
cc_proto_library(
184151
name = "request_proto",
185152
srcs = ["polaris/proto/v1/request.proto"],
153+
include = "polaris/proto",
186154
deps = [
187155
":service_proto",
188156
],
189-
include = "polaris/proto",
190157
)
191158

192159
cc_proto_library(
193160
name = "service_proto",
194161
srcs = ["polaris/proto/v1/service.proto"],
162+
include = "polaris/proto",
195163
deps = [
196164
":model_proto",
197-
"@com_google_protobuf//:cc_wkt_protos"
165+
"@com_google_protobuf//:cc_wkt_protos",
198166
],
199-
include = "polaris/proto",
200167
)
201168

202169
cc_proto_library(
203170
name = "ratelimit_proto",
204171
srcs = ["polaris/proto/v1/ratelimit.proto"],
172+
include = "polaris/proto",
205173
deps = [
206174
":model_proto",
207-
"@com_google_protobuf//:cc_wkt_protos"
175+
"@com_google_protobuf//:cc_wkt_protos",
208176
],
209-
include = "polaris/proto",
210177
)
211178

212179
cc_proto_library(
213180
name = "ratelimit_proto_v2",
214181
srcs = ["polaris/proto/v2/ratelimit_v2.proto"],
182+
include = "polaris/proto",
215183
deps = [
216-
"@com_google_protobuf//:cc_wkt_protos"
184+
"@com_google_protobuf//:cc_wkt_protos",
217185
],
218-
include = "polaris/proto",
219186
)
220187

221188
cc_proto_library(
222189
name = "circuit_breaker_proto",
223190
srcs = ["polaris/proto/v1/circuitbreaker.proto"],
224-
deps = [
225-
":model_proto",
226-
"@com_google_protobuf//:cc_wkt_protos"
227-
],
228191
include = "polaris/proto",
192+
deps = [
193+
":model_proto",
194+
"@com_google_protobuf//:cc_wkt_protos",
195+
],
229196
)
230197

231198
cc_proto_library(
232199
name = "metric_proto",
233200
srcs = ["polaris/proto/v1/metric.proto"],
201+
include = "polaris/proto",
234202
deps = ["@com_google_protobuf//:cc_wkt_protos"],
203+
)
204+
205+
cc_proto_library(
206+
name = "dynamicweight_proto",
207+
srcs = ["polaris/proto/v1/dynamicweight.proto"],
235208
include = "polaris/proto",
209+
deps = ["@com_google_protobuf//:cc_wkt_protos"],
236210
)
237211

238212
cc_proto_library(
239213
name = "model_proto",
240214
srcs = ["polaris/proto/v1/model.proto"],
215+
include = "polaris/proto",
241216
deps = [
242-
"@com_google_protobuf//:cc_wkt_protos"
217+
"@com_google_protobuf//:cc_wkt_protos",
243218
],
244-
include = "polaris/proto",
245219
)
246220

247221
cc_proto_library(
@@ -250,6 +224,16 @@ cc_proto_library(
250224
include = "polaris/proto",
251225
)
252226

227+
#trpc协议头
228+
cc_proto_library(
229+
name = "trpc_proto",
230+
srcs = ["polaris/proto/v1/trpc.proto"],
231+
include = "polaris/proto",
232+
deps = [
233+
"@com_google_protobuf//:cc_wkt_protos",
234+
],
235+
)
236+
253237
cc_library(
254238
name = "test",
255239
srcs = glob([
@@ -259,21 +243,20 @@ cc_library(
259243
hdrs = glob([
260244
"include/**/*.h",
261245
]),
262-
deps = [
263-
":trpcapi_cc_trpc",
264-
":code_cc_proto",
265-
":yaml-cpp-polaris-internal",
266-
":nghttp2",
267-
":murmurhash",
268-
":re2",
269-
":ratelimit_proto_v2",
270-
],
271246
includes = [
272247
"include",
273248
"polaris",
274249
],
275250
visibility = [
276251
"//visibility:public",
277252
],
253+
deps = [
254+
":code_cc_proto",
255+
":murmurhash",
256+
":nghttp2",
257+
":ratelimit_proto_v2",
258+
":trpcapi_cc_trpc",
259+
":yaml-cpp-polaris-internal",
260+
"@com_googlesource_code_re2//:re2",
261+
],
278262
)
279-

0 commit comments

Comments
 (0)