-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
799 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Copyright 2020 the gRPC authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library") | ||
load("@com_github_grpc_grpc//bazel:grpc_build_system.bzl", "grpc_proto_library") | ||
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library") | ||
|
||
licenses(["notice"]) | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
# The following three rules demonstrate the usage of the cc_grpc_library rule in | ||
# in a mode compatible with the native proto_library and cc_proto_library rules. | ||
proto_library( | ||
name = "helloworld_proto", | ||
srcs = ["helloworld.proto"], | ||
) | ||
|
||
cc_proto_library( | ||
name = "helloworld_cc_proto", | ||
deps = [":helloworld_proto"], | ||
) | ||
|
||
cc_grpc_library( | ||
name = "helloworld_cc_grpc", | ||
srcs = [":helloworld_proto"], | ||
grpc_only = True, | ||
deps = [":helloworld_cc_proto"], | ||
) | ||
|
||
## data_stream proto | ||
proto_library( | ||
name = "data_proto", | ||
srcs = ["data.proto"], | ||
) | ||
cc_proto_library( | ||
name = "data_cc_proto", | ||
deps = [":data_proto"], | ||
) | ||
|
||
cc_grpc_library( | ||
name = "data_cc_grpc", | ||
srcs = [":data_proto"], | ||
grpc_only = True, | ||
deps = [":data_cc_proto"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2019 gRPC authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// 语法版本声明,必须放在非注释的第一行 | ||
// Syntax version declaration. Must be placed on the first line of non-commentary. | ||
|
||
syntax = "proto3"; | ||
// The document of proto3: https://developers.google.com/protocol-buffers/docs/proto3 | ||
|
||
// 包名定义, Python中使用时可以省略不写 | ||
// Package name definition, which can be omitted in Python. | ||
package data; | ||
|
||
/* | ||
`message`是用来定义传输的数据的格式的, 等号后面的是字段编号 | ||
消息定义中的每个字段都有唯一的编号 | ||
总体格式类似于Python中定义一个类或者Golang中定义一个结构体 | ||
*/ | ||
/* | ||
`message` is used to define the structure of the data to be transmitted, after the equal sign | ||
is the field number. Each field in the message definition has a unique number. | ||
The overall format is similar to defining a class in Python or a structure in Golang. | ||
*/ | ||
message Request { | ||
bytes data=2; | ||
} | ||
|
||
message Response { | ||
bytes data=2; | ||
} | ||
|
||
// `service` 是用来给gRPC服务定义方法的, 格式固定, 类似于Golang中定义一个接口 | ||
// `service` is used to define methods for gRPC services in a fixed format, similar to defining | ||
//an interface in Golang | ||
service GRPCDemo { | ||
// 客户端流模式(在一次调用中, 客户端可以多次向服务器传输数据, 但是服务器只能返回一次响应) | ||
// stream-unary (In a single call, the client can transfer data to the server several times, | ||
// but the server can only return a response once.) | ||
rpc StreamingMethod (stream Request) returns (stream Response); | ||
rpc UnaryMethod (Request) returns (Response); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2015 gRPC authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.grpc.examples.helloworld"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
option objc_class_prefix = "HLW"; | ||
|
||
package helloworld; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
|
||
rpc SayHelloStreamReply (HelloRequest) returns (stream HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Copyright 2020 the gRPC authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
licenses(["notice"]) | ||
|
||
cc_binary( | ||
name = "sync_client", | ||
srcs = ["sync_client.cc"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
|
||
) | ||
cc_binary( | ||
name = "client_multi", | ||
srcs = ["client_multi.cc","thread_pool.hpp"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
|
||
) | ||
|
||
|
||
cc_binary( | ||
name = "sync_server", | ||
srcs = ["sync_server.cc"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"@com_github_grpc_grpc//:grpc++_reflection", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
"@com_google_absl//absl/strings:str_format", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
) | ||
cc_binary( | ||
name = "async_server", | ||
srcs = ["async_server.cc"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"@com_github_grpc_grpc//:grpc++_reflection", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
"@com_google_absl//absl/strings:str_format", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
) | ||
|
||
cc_binary( | ||
name = "async_client", | ||
srcs = ["async_client.cc"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
|
||
) | ||
|
||
|
||
cc_binary( | ||
name = "grpc_async_client", | ||
srcs = ["greeter_async_client.cc"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
|
||
) | ||
|
||
cc_binary( | ||
name = "grpc_async_server", | ||
srcs = ["greeter_async_server.cc"], | ||
defines = ["BAZEL_BUILD"], | ||
deps = [ | ||
"@com_github_grpc_grpc//:grpc++", | ||
"@com_github_grpc_grpc//:grpc++_reflection", | ||
"//examples/protos:helloworld_cc_grpc", | ||
"@com_google_absl//absl/flags:flag", | ||
"@com_google_absl//absl/flags:parse", | ||
"@com_google_absl//absl/strings:str_format", | ||
], | ||
linkshared = False, | ||
linkstatic = True, | ||
) |
Oops, something went wrong.