mirror of https://github.com/grpc/grpc.git
commit
d2492644aa
822 changed files with 48368 additions and 14904 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@ |
|||||||
|
There are times when we make changes that include a temporary shim for |
||||||
|
backward-compatibility (e.g., a macro or some other function to preserve |
||||||
|
the original API) to avoid having to bump the major version number in |
||||||
|
the next release. However, when we do eventually want to release a |
||||||
|
feature that does change the API in a non-backward-compatible way, we |
||||||
|
will wind up bumping the major version number anyway, at which point we |
||||||
|
can take the opportunity to clean up any pending backward-compatibility |
||||||
|
shims. |
||||||
|
|
||||||
|
This file lists all pending backward-compatibility changes that should |
||||||
|
be cleaned up the next time we are going to bump the major version |
||||||
|
number: |
||||||
|
|
||||||
|
- remove `GRPC_ARG_MAX_MESSAGE_LENGTH` channel arg from |
||||||
|
`include/grpc/impl/codegen/grpc_types.h` (commit `af00d8b`) |
@ -1,15 +1 @@ |
|||||||
gRPC Fail Fast Semantics |
Moved to wait-for-ready.md |
||||||
======================== |
|
||||||
|
|
||||||
Fail fast requests allow terminating requests (with status UNAVAILABLE) prior |
|
||||||
to the deadline of the request being met. |
|
||||||
|
|
||||||
gRPC implementations of fail fast can terminate requests whenever a channel is |
|
||||||
in the TRANSIENT_FAILURE or SHUTDOWN states. If the channel is in any other |
|
||||||
state (CONNECTING, READY, or IDLE) the request should not be terminated. |
|
||||||
|
|
||||||
Fail fast SHOULD be the default for gRPC implementations, with an option to |
|
||||||
switch to non fail fast. |
|
||||||
|
|
||||||
The opposite of fail fast is 'ignore connectivity'. |
|
||||||
|
|
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
Each version of gRPC gets a new description of what the 'g' stands for, since |
||||||
|
we've never really been able to figure it out. |
||||||
|
|
||||||
|
Below is a list of already-used definitions (that should not be repeated in the |
||||||
|
future), and the corresponding version numbers that used them: |
||||||
|
|
||||||
|
- 1.0 'g' stands for 'gRPC' |
||||||
|
- 1.1 'g' stands for 'good' |
@ -0,0 +1,30 @@ |
|||||||
|
# HTTP to gRPC Status Code Mapping |
||||||
|
|
||||||
|
Since intermediaries are a common part of HTTP infrastructure some responses to |
||||||
|
gRPC requests may be received that do not include the grpc-status header. In |
||||||
|
some cases mapping error codes from an intermediary allows the gRPC client to |
||||||
|
behave more appropriately to the error situation without overloading the |
||||||
|
semantics of either error code. |
||||||
|
|
||||||
|
This table is to be used _only_ for clients that received a response that did |
||||||
|
not include grpc-status. If grpc-status was provided, it _must_ be used. Servers |
||||||
|
_must not_ use this table to determine an HTTP status code to use; the mappings |
||||||
|
are neither symmetric nor 1-to-1. |
||||||
|
|
||||||
|
| HTTP Status Code | gRPC Status Code | |
||||||
|
|----------------------------|--------------------| |
||||||
|
| 400 Bad Request | INTERNAL | |
||||||
|
| 401 Unauthorized | UNAUTHENTICATED | |
||||||
|
| 403 Forbidden | PERMISSION\_DENIED | |
||||||
|
| 404 Not Found | UNIMPLEMENTED | |
||||||
|
| 429 Too Many Requests | UNAVAILABLE | |
||||||
|
| 502 Bad Gateway | UNAVAILABLE | |
||||||
|
| 503 Service Unavailable | UNAVAILABLE | |
||||||
|
| 504 Gateway Timeout | UNAVAILABLE | |
||||||
|
| _All other codes_ | UNKNOWN | |
||||||
|
|
||||||
|
Technically, 1xx should have the entire header skipped and a subsequent header |
||||||
|
be read. See RFC 7540 §8.1. |
||||||
|
|
||||||
|
200 is UNKNOWN because there should be a grpc-status in case of truly OK |
||||||
|
response. |
@ -0,0 +1,192 @@ |
|||||||
|
# gRPC Server Reflection Tutorial |
||||||
|
|
||||||
|
gRPC Server Reflection provides information about publicly-accessible gRPC |
||||||
|
services on a server, and assists clients at runtime to construct RPC |
||||||
|
requests and responses without precompiled service information. It is used by |
||||||
|
gRPC CLI, which can be used to introspect server protos and send/receive test |
||||||
|
RPCs. |
||||||
|
|
||||||
|
## Enable Server Reflection |
||||||
|
|
||||||
|
### Enable server reflection in C++ servers |
||||||
|
|
||||||
|
C++ Server Reflection is an add-on library, `libgrpc++_reflction`. To enable C++ |
||||||
|
server reflection, you can link this library to your server binary. |
||||||
|
|
||||||
|
Some platforms (e.g. Ubuntu 11.10 onwards) only link in libraries that directly |
||||||
|
contain symbols used by the application. On these platforms, LD flag |
||||||
|
`--no-as-needed` is needed for for dynamic linking and `--whole-archive` is |
||||||
|
needed for for static linking. |
||||||
|
|
||||||
|
This [Makefile](../examples/cpp/helloworld/Makefile#L37#L45) demonstrates |
||||||
|
enabling c++ server reflection on Linux and MacOS. |
||||||
|
|
||||||
|
## Test services using Server Reflection |
||||||
|
|
||||||
|
After enabling Server Reflection in a server application, you can use gRPC CLI |
||||||
|
to test its services. |
||||||
|
|
||||||
|
Instructions on how to use gRPC CLI can be found at |
||||||
|
[command_line_tool.md](command_line_tool.md), or using `grpc_cli help` command. |
||||||
|
|
||||||
|
Here we use `examples/cpp/helloworld` as an example to show the use of gRPC |
||||||
|
Server Reflection and gRPC CLI. First, we need to build gRPC CLI and setup an |
||||||
|
example server with Server Reflection enabled. |
||||||
|
|
||||||
|
- Setup an example server |
||||||
|
|
||||||
|
Server Reflection has already been enabled in the |
||||||
|
[Makefile](../examples/cpp/helloworld/Makefile) of the helloworld example. We |
||||||
|
can simply make it and run the greeter_server. |
||||||
|
|
||||||
|
```sh |
||||||
|
$ make -C examples/cpp/helloworld |
||||||
|
$ examples/cpp/helloworld/greeter_server & |
||||||
|
``` |
||||||
|
|
||||||
|
- Build gRPC CLI |
||||||
|
|
||||||
|
```sh |
||||||
|
make grpc_cli |
||||||
|
cd bins/opt |
||||||
|
``` |
||||||
|
|
||||||
|
gRPC CLI binary `grpc_cli` can be found at `bins/opt/` folder. This tool is |
||||||
|
still new and does not have a `make install` target yet. |
||||||
|
|
||||||
|
### List services |
||||||
|
|
||||||
|
`grpc_cli ls` command lists services and methods exposed at a given port |
||||||
|
|
||||||
|
- List all the services exposed at a given port |
||||||
|
|
||||||
|
```sh |
||||||
|
$ grpc_cli ls localhost:50051 |
||||||
|
``` |
||||||
|
|
||||||
|
output: |
||||||
|
```sh |
||||||
|
helloworld.Greeter |
||||||
|
grpc.reflection.v1alpha.ServerReflection |
||||||
|
``` |
||||||
|
|
||||||
|
- List one service with details |
||||||
|
|
||||||
|
`grpc_cli ls` command inspects a service given its full name (in the format of |
||||||
|
\<package\>.\<service\>). It can print information with a long listing format |
||||||
|
when `-l` flag is set. This flag can be used to get more details about a |
||||||
|
service. |
||||||
|
|
||||||
|
```sh |
||||||
|
$ grpc_cli ls localhost:50051 helloworld.Greeter -l |
||||||
|
``` |
||||||
|
|
||||||
|
output: |
||||||
|
```sh |
||||||
|
filename: helloworld.proto |
||||||
|
package: helloworld; |
||||||
|
service Greeter { |
||||||
|
rpc SayHello(helloworld.HelloRequest) returns (helloworld.HelloReply) {} |
||||||
|
} |
||||||
|
|
||||||
|
``` |
||||||
|
|
||||||
|
### List methods |
||||||
|
|
||||||
|
- List one method with details |
||||||
|
|
||||||
|
`grpc_cli ls` command also inspects a method given its full name (in the |
||||||
|
format of \<package\>.\<service\>.\<method\>). |
||||||
|
|
||||||
|
```sh |
||||||
|
$ grpc_cli ls localhost:50051 helloworld.Greeter.SayHello -l |
||||||
|
``` |
||||||
|
|
||||||
|
output: |
||||||
|
```sh |
||||||
|
rpc SayHello(helloworld.HelloRequest) returns (helloworld.HelloReply) {} |
||||||
|
``` |
||||||
|
|
||||||
|
### Inspect message types |
||||||
|
|
||||||
|
We can use`grpc_cli type` command to inspect request/response types given the |
||||||
|
full name of the type (in the format of \<package\>.\<type\>). |
||||||
|
|
||||||
|
- Get information about the request type |
||||||
|
|
||||||
|
```sh |
||||||
|
$ grpc_cli type localhost:50051 helloworld.HelloRequest |
||||||
|
``` |
||||||
|
|
||||||
|
output: |
||||||
|
```sh |
||||||
|
message HelloRequest { |
||||||
|
optional string name = 1; |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
### Call a remote method |
||||||
|
|
||||||
|
We can send RPCs to a server and get responses using `grpc_cli call` command. |
||||||
|
|
||||||
|
- Call a unary method |
||||||
|
|
||||||
|
```sh |
||||||
|
$ grpc_cli call localhost:50051 SayHello "name: 'gRPC CLI'" |
||||||
|
``` |
||||||
|
|
||||||
|
output: |
||||||
|
```sh |
||||||
|
message: "Hello gRPC CLI" |
||||||
|
``` |
||||||
|
|
||||||
|
## Use Server Reflection in a C++ client |
||||||
|
|
||||||
|
Server Reflection can be used by clients to get information about gRPC services |
||||||
|
at runtime. We've provided a descriptor database called |
||||||
|
[grpc::ProtoReflectionDescriptorDatabase](../test/cpp/util/proto_reflection_descriptor_database.h) |
||||||
|
which implements the |
||||||
|
[google::protobuf::DescriptorDatabase](https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor_database#DescriptorDatabase) |
||||||
|
interface. It manages the communication between clients and reflection services |
||||||
|
and the storage of received information. Clients can use it as using a local |
||||||
|
descriptor database. |
||||||
|
|
||||||
|
- To use Server Reflection with grpc::ProtoReflectionDescriptorDatabase, first |
||||||
|
initialize an instance with a grpc::Channel. |
||||||
|
|
||||||
|
```c++ |
||||||
|
std::shared_ptr<grpc::Channel> channel = |
||||||
|
grpc::CreateChannel(server_address, server_cred); |
||||||
|
grpc::ProtoReflectionDescriptorDatabase reflection_db(channel); |
||||||
|
``` |
||||||
|
|
||||||
|
- Then use this instance to feed a |
||||||
|
[google::protobuf::DescriptorPool](https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor#DescriptorPool). |
||||||
|
|
||||||
|
```c++ |
||||||
|
google::protobuf::DescriptorPool desc_pool(&reflection_db); |
||||||
|
``` |
||||||
|
|
||||||
|
- Example usage of this descriptor pool |
||||||
|
|
||||||
|
* Get Service/method descriptors. |
||||||
|
|
||||||
|
```c++ |
||||||
|
const google::protobuf::ServiceDescriptor* service_desc = |
||||||
|
desc_pool->FindServiceByName("helloworld.Greeter"); |
||||||
|
const google::protobuf::MethodDescriptor* method_desc = |
||||||
|
desc_pool->FindMethodByName("helloworld.Greeter.SayHello"); |
||||||
|
``` |
||||||
|
|
||||||
|
* Get message type descriptors. |
||||||
|
|
||||||
|
```c++ |
||||||
|
const google::protobuf::Descriptor* request_desc = |
||||||
|
desc_pool->FindMessageTypeByName("helloworld.HelloRequest"); |
||||||
|
``` |
||||||
|
|
||||||
|
* Feed [google::protobuf::DynamicMessageFactory](https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.dynamic_message#DynamicMessageFactory). |
||||||
|
|
||||||
|
```c++ |
||||||
|
google::protobuf::DynamicMessageFactory(&desc_pool); |
||||||
|
``` |
@ -0,0 +1,14 @@ |
|||||||
|
gRPC Wait for Ready Semantics |
||||||
|
============================= |
||||||
|
|
||||||
|
If an RPC is issued but the channel is in `TRANSIENT_FAILURE` or `SHUTDOWN` |
||||||
|
states, the RPC is unable to be transmited promptly. By default, gRPC |
||||||
|
implementations SHOULD fail such RPCs immediately. This is known as "fail fast," |
||||||
|
but usage of the term is historical. RPCs SHOULD NOT fail as a result of the |
||||||
|
channel being in other states (`CONNECTING`, `READY`, or `IDLE`). |
||||||
|
|
||||||
|
gRPC implementations MAY provide a per-RPC option to not fail RPCs as a result |
||||||
|
of the channel being in `TRANSIENT_FAILURE` state. Instead, the implementation |
||||||
|
queues the RPCs until the channel is `READY`. This is known as "wait for ready." |
||||||
|
The RPCs SHOULD still fail before `READY` if there are unrelated reasons, such |
||||||
|
as the channel is `SHUTDOWN` or the RPC's deadline is reached. |
@ -0,0 +1,4 @@ |
|||||||
|
The roots.pem file is periodically generated from: |
||||||
|
https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt |
||||||
|
using |
||||||
|
https://github.com/agl/extract-nss-root-certs |
@ -0,0 +1,259 @@ |
|||||||
|
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||||
|
// source: helloworld.proto |
||||||
|
#pragma warning disable 1591, 0612, 3021 |
||||||
|
#region Designer generated code |
||||||
|
|
||||||
|
using pb = global::Google.Protobuf; |
||||||
|
using pbc = global::Google.Protobuf.Collections; |
||||||
|
using pbr = global::Google.Protobuf.Reflection; |
||||||
|
using scg = global::System.Collections.Generic; |
||||||
|
namespace Helloworld { |
||||||
|
|
||||||
|
/// <summary>Holder for reflection information generated from helloworld.proto</summary> |
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||||
|
public static partial class HelloworldReflection { |
||||||
|
|
||||||
|
#region Descriptor |
||||||
|
/// <summary>File descriptor for helloworld.proto</summary> |
||||||
|
public static pbr::FileDescriptor Descriptor { |
||||||
|
get { return descriptor; } |
||||||
|
} |
||||||
|
private static pbr::FileDescriptor descriptor; |
||||||
|
|
||||||
|
static HelloworldReflection() { |
||||||
|
byte[] descriptorData = global::System.Convert.FromBase64String( |
||||||
|
string.Concat( |
||||||
|
"ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz", |
||||||
|
"dBIMCgRuYW1lGAEgASgJIh0KCkhlbGxvUmVwbHkSDwoHbWVzc2FnZRgBIAEo", |
||||||
|
"CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl", |
||||||
|
"cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEI2Chtpby5ncnBjLmV4", |
||||||
|
"YW1wbGVzLmhlbGxvd29ybGRCD0hlbGxvV29ybGRQcm90b1ABogIDSExXYgZw", |
||||||
|
"cm90bzM=")); |
||||||
|
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, |
||||||
|
new pbr::FileDescriptor[] { }, |
||||||
|
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { |
||||||
|
new pbr::GeneratedClrTypeInfo(typeof(global::Helloworld.HelloRequest), global::Helloworld.HelloRequest.Parser, new[]{ "Name" }, null, null, null), |
||||||
|
new pbr::GeneratedClrTypeInfo(typeof(global::Helloworld.HelloReply), global::Helloworld.HelloReply.Parser, new[]{ "Message" }, null, null, null) |
||||||
|
})); |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
|
#region Messages |
||||||
|
/// <summary> |
||||||
|
/// The request message containing the user's name. |
||||||
|
/// </summary> |
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||||
|
public sealed partial class HelloRequest : pb::IMessage<HelloRequest> { |
||||||
|
private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest()); |
||||||
|
public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } } |
||||||
|
|
||||||
|
public static pbr::MessageDescriptor Descriptor { |
||||||
|
get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } |
||||||
|
} |
||||||
|
|
||||||
|
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||||
|
get { return Descriptor; } |
||||||
|
} |
||||||
|
|
||||||
|
public HelloRequest() { |
||||||
|
OnConstruction(); |
||||||
|
} |
||||||
|
|
||||||
|
partial void OnConstruction(); |
||||||
|
|
||||||
|
public HelloRequest(HelloRequest other) : this() { |
||||||
|
name_ = other.name_; |
||||||
|
} |
||||||
|
|
||||||
|
public HelloRequest Clone() { |
||||||
|
return new HelloRequest(this); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>Field number for the "name" field.</summary> |
||||||
|
public const int NameFieldNumber = 1; |
||||||
|
private string name_ = ""; |
||||||
|
public string Name { |
||||||
|
get { return name_; } |
||||||
|
set { |
||||||
|
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override bool Equals(object other) { |
||||||
|
return Equals(other as HelloRequest); |
||||||
|
} |
||||||
|
|
||||||
|
public bool Equals(HelloRequest other) { |
||||||
|
if (ReferenceEquals(other, null)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
if (ReferenceEquals(other, this)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
if (Name != other.Name) return false; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public override int GetHashCode() { |
||||||
|
int hash = 1; |
||||||
|
if (Name.Length != 0) hash ^= Name.GetHashCode(); |
||||||
|
return hash; |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() { |
||||||
|
return pb::JsonFormatter.ToDiagnosticString(this); |
||||||
|
} |
||||||
|
|
||||||
|
public void WriteTo(pb::CodedOutputStream output) { |
||||||
|
if (Name.Length != 0) { |
||||||
|
output.WriteRawTag(10); |
||||||
|
output.WriteString(Name); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int CalculateSize() { |
||||||
|
int size = 0; |
||||||
|
if (Name.Length != 0) { |
||||||
|
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); |
||||||
|
} |
||||||
|
return size; |
||||||
|
} |
||||||
|
|
||||||
|
public void MergeFrom(HelloRequest other) { |
||||||
|
if (other == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (other.Name.Length != 0) { |
||||||
|
Name = other.Name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void MergeFrom(pb::CodedInputStream input) { |
||||||
|
uint tag; |
||||||
|
while ((tag = input.ReadTag()) != 0) { |
||||||
|
switch(tag) { |
||||||
|
default: |
||||||
|
input.SkipLastField(); |
||||||
|
break; |
||||||
|
case 10: { |
||||||
|
Name = input.ReadString(); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// The response message containing the greetings |
||||||
|
/// </summary> |
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||||
|
public sealed partial class HelloReply : pb::IMessage<HelloReply> { |
||||||
|
private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply()); |
||||||
|
public static pb::MessageParser<HelloReply> Parser { get { return _parser; } } |
||||||
|
|
||||||
|
public static pbr::MessageDescriptor Descriptor { |
||||||
|
get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } |
||||||
|
} |
||||||
|
|
||||||
|
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||||
|
get { return Descriptor; } |
||||||
|
} |
||||||
|
|
||||||
|
public HelloReply() { |
||||||
|
OnConstruction(); |
||||||
|
} |
||||||
|
|
||||||
|
partial void OnConstruction(); |
||||||
|
|
||||||
|
public HelloReply(HelloReply other) : this() { |
||||||
|
message_ = other.message_; |
||||||
|
} |
||||||
|
|
||||||
|
public HelloReply Clone() { |
||||||
|
return new HelloReply(this); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>Field number for the "message" field.</summary> |
||||||
|
public const int MessageFieldNumber = 1; |
||||||
|
private string message_ = ""; |
||||||
|
public string Message { |
||||||
|
get { return message_; } |
||||||
|
set { |
||||||
|
message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override bool Equals(object other) { |
||||||
|
return Equals(other as HelloReply); |
||||||
|
} |
||||||
|
|
||||||
|
public bool Equals(HelloReply other) { |
||||||
|
if (ReferenceEquals(other, null)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
if (ReferenceEquals(other, this)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
if (Message != other.Message) return false; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public override int GetHashCode() { |
||||||
|
int hash = 1; |
||||||
|
if (Message.Length != 0) hash ^= Message.GetHashCode(); |
||||||
|
return hash; |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() { |
||||||
|
return pb::JsonFormatter.ToDiagnosticString(this); |
||||||
|
} |
||||||
|
|
||||||
|
public void WriteTo(pb::CodedOutputStream output) { |
||||||
|
if (Message.Length != 0) { |
||||||
|
output.WriteRawTag(10); |
||||||
|
output.WriteString(Message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public int CalculateSize() { |
||||||
|
int size = 0; |
||||||
|
if (Message.Length != 0) { |
||||||
|
size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); |
||||||
|
} |
||||||
|
return size; |
||||||
|
} |
||||||
|
|
||||||
|
public void MergeFrom(HelloReply other) { |
||||||
|
if (other == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (other.Message.Length != 0) { |
||||||
|
Message = other.Message; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void MergeFrom(pb::CodedInputStream input) { |
||||||
|
uint tag; |
||||||
|
while ((tag = input.ReadTag()) != 0) { |
||||||
|
switch(tag) { |
||||||
|
default: |
||||||
|
input.SkipLastField(); |
||||||
|
break; |
||||||
|
case 10: { |
||||||
|
Message = input.ReadString(); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion Designer generated code |
@ -0,0 +1,143 @@ |
|||||||
|
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||||
|
// source: helloworld.proto |
||||||
|
// Original file comments: |
||||||
|
// Copyright 2015, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
// |
||||||
|
#region Designer generated code |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Threading; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Grpc.Core; |
||||||
|
|
||||||
|
namespace Helloworld { |
||||||
|
/// <summary> |
||||||
|
/// The greeting service definition. |
||||||
|
/// </summary> |
||||||
|
public static class Greeter |
||||||
|
{ |
||||||
|
static readonly string __ServiceName = "helloworld.Greeter"; |
||||||
|
|
||||||
|
static readonly Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom); |
||||||
|
static readonly Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom); |
||||||
|
|
||||||
|
static readonly Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>( |
||||||
|
MethodType.Unary, |
||||||
|
__ServiceName, |
||||||
|
"SayHello", |
||||||
|
__Marshaller_HelloRequest, |
||||||
|
__Marshaller_HelloReply); |
||||||
|
|
||||||
|
/// <summary>Service descriptor</summary> |
||||||
|
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor |
||||||
|
{ |
||||||
|
get { return global::Helloworld.HelloworldReflection.Descriptor.Services[0]; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>Base class for server-side implementations of Greeter</summary> |
||||||
|
public abstract class GreeterBase |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Sends a greeting |
||||||
|
/// </summary> |
||||||
|
public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, ServerCallContext context) |
||||||
|
{ |
||||||
|
throw new RpcException(new Status(StatusCode.Unimplemented, "")); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>Client for Greeter</summary> |
||||||
|
public class GreeterClient : ClientBase<GreeterClient> |
||||||
|
{ |
||||||
|
/// <summary>Creates a new client for Greeter</summary> |
||||||
|
/// <param name="channel">The channel to use to make remote calls.</param> |
||||||
|
public GreeterClient(Channel channel) : base(channel) |
||||||
|
{ |
||||||
|
} |
||||||
|
/// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary> |
||||||
|
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param> |
||||||
|
public GreeterClient(CallInvoker callInvoker) : base(callInvoker) |
||||||
|
{ |
||||||
|
} |
||||||
|
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary> |
||||||
|
protected GreeterClient() : base() |
||||||
|
{ |
||||||
|
} |
||||||
|
/// <summary>Protected constructor to allow creation of configured clients.</summary> |
||||||
|
/// <param name="configuration">The client configuration.</param> |
||||||
|
protected GreeterClient(ClientBaseConfiguration configuration) : base(configuration) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Sends a greeting |
||||||
|
/// </summary> |
||||||
|
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) |
||||||
|
{ |
||||||
|
return SayHello(request, new CallOptions(headers, deadline, cancellationToken)); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Sends a greeting |
||||||
|
/// </summary> |
||||||
|
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options) |
||||||
|
{ |
||||||
|
return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Sends a greeting |
||||||
|
/// </summary> |
||||||
|
public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) |
||||||
|
{ |
||||||
|
return SayHelloAsync(request, new CallOptions(headers, deadline, cancellationToken)); |
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// Sends a greeting |
||||||
|
/// </summary> |
||||||
|
public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options) |
||||||
|
{ |
||||||
|
return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request); |
||||||
|
} |
||||||
|
protected override GreeterClient NewInstance(ClientBaseConfiguration configuration) |
||||||
|
{ |
||||||
|
return new GreeterClient(configuration); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>Creates service definition that can be registered with a server</summary> |
||||||
|
public static ServerServiceDefinition BindService(GreeterBase serviceImpl) |
||||||
|
{ |
||||||
|
return ServerServiceDefinition.CreateBuilder() |
||||||
|
.AddMethod(__Method_SayHello, serviceImpl.SayHello).Build(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
#endregion |
@ -0,0 +1,22 @@ |
|||||||
|
{ |
||||||
|
"title": "Greeter", |
||||||
|
"version": "1.0.0-*", |
||||||
|
"buildOptions": { |
||||||
|
"debugType": "portable", |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"Google.Protobuf": "3.0.0", |
||||||
|
"Grpc": "1.0.0", |
||||||
|
}, |
||||||
|
"frameworks": { |
||||||
|
"net45": { |
||||||
|
"frameworkAssemblies": { |
||||||
|
"System.Runtime": "", |
||||||
|
"System.IO": "" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"Microsoft.NETCore.Platforms": "1.0.1" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
// Copyright 2015, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
using System; |
||||||
|
using Grpc.Core; |
||||||
|
using Helloworld; |
||||||
|
|
||||||
|
namespace GreeterClient |
||||||
|
{ |
||||||
|
class Program |
||||||
|
{ |
||||||
|
public static void Main(string[] args) |
||||||
|
{ |
||||||
|
Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure); |
||||||
|
|
||||||
|
var client = new Greeter.GreeterClient(channel); |
||||||
|
String user = "you"; |
||||||
|
|
||||||
|
var reply = client.SayHello(new HelloRequest { Name = user }); |
||||||
|
Console.WriteLine("Greeting: " + reply.Message); |
||||||
|
|
||||||
|
channel.ShutdownAsync().Wait(); |
||||||
|
Console.WriteLine("Press any key to exit..."); |
||||||
|
Console.ReadKey(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
{ |
||||||
|
"title": "GreeterClient", |
||||||
|
"version": "1.0.0-*", |
||||||
|
"buildOptions": { |
||||||
|
"debugType": "portable", |
||||||
|
"emitEntryPoint": "true" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"Google.Protobuf": "3.0.0", |
||||||
|
"Grpc": "1.0.0", |
||||||
|
"Greeter": { |
||||||
|
"target": "project" |
||||||
|
} |
||||||
|
}, |
||||||
|
"frameworks": { |
||||||
|
"net45": { |
||||||
|
"frameworkAssemblies": { |
||||||
|
"System.Runtime": "", |
||||||
|
"System.IO": "" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"Microsoft.NETCore.Platforms": "1.0.1" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
// Copyright 2015, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Grpc.Core; |
||||||
|
using Helloworld; |
||||||
|
|
||||||
|
namespace GreeterServer |
||||||
|
{ |
||||||
|
class GreeterImpl : Greeter.GreeterBase |
||||||
|
{ |
||||||
|
// Server side handler of the SayHello RPC |
||||||
|
public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context) |
||||||
|
{ |
||||||
|
return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class Program |
||||||
|
{ |
||||||
|
const int Port = 50051; |
||||||
|
|
||||||
|
public static void Main(string[] args) |
||||||
|
{ |
||||||
|
Server server = new Server |
||||||
|
{ |
||||||
|
Services = { Greeter.BindService(new GreeterImpl()) }, |
||||||
|
Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } |
||||||
|
}; |
||||||
|
server.Start(); |
||||||
|
|
||||||
|
Console.WriteLine("Greeter server listening on port " + Port); |
||||||
|
Console.WriteLine("Press any key to stop the server..."); |
||||||
|
Console.ReadKey(); |
||||||
|
|
||||||
|
server.ShutdownAsync().Wait(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
{ |
||||||
|
"title": "GreeterServer", |
||||||
|
"version": "1.0.0-*", |
||||||
|
"buildOptions": { |
||||||
|
"debugType": "portable", |
||||||
|
"emitEntryPoint": "true" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"Google.Protobuf": "3.0.0", |
||||||
|
"Grpc": "1.0.0", |
||||||
|
"Greeter": { |
||||||
|
"target": "project" |
||||||
|
} |
||||||
|
}, |
||||||
|
"frameworks": { |
||||||
|
"net45": { |
||||||
|
"frameworkAssemblies": { |
||||||
|
"System.Runtime": "", |
||||||
|
"System.IO": "" |
||||||
|
}, |
||||||
|
"dependencies": { |
||||||
|
"Microsoft.NETCore.Platforms": "1.0.1" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
gRPC in 3 minutes (C#) |
||||||
|
======================== |
||||||
|
|
||||||
|
BACKGROUND |
||||||
|
------------- |
||||||
|
This is a different version of the helloworld example, using the dotnet sdk |
||||||
|
tools to build and run. |
||||||
|
|
||||||
|
For this sample, we've already generated the server and client stubs from [helloworld.proto][]. |
||||||
|
|
||||||
|
Example projects in this directory depend on the [Grpc](https://www.nuget.org/packages/Grpc/) |
||||||
|
and [Google.Protobuf](https://www.nuget.org/packages/Google.Protobuf/) NuGet packages |
||||||
|
which have been already added to the project for you. |
||||||
|
|
||||||
|
The examples in this directory target .NET 4.5 framework, as .NET Core support is |
||||||
|
currently experimental. |
||||||
|
|
||||||
|
PREREQUISITES |
||||||
|
------------- |
||||||
|
|
||||||
|
- The DotNetCore SDK cli. |
||||||
|
|
||||||
|
- The .NET 4.5 framework. |
||||||
|
|
||||||
|
Both are available to download at https://www.microsoft.com/net/download |
||||||
|
|
||||||
|
BUILD |
||||||
|
------- |
||||||
|
|
||||||
|
From the `examples/csharp/helloworld-from-cli` directory: |
||||||
|
|
||||||
|
- `dotnet restore` |
||||||
|
|
||||||
|
- `dotnet build **/project.json` (this will automatically download NuGet dependencies) |
||||||
|
|
||||||
|
Try it! |
||||||
|
------- |
||||||
|
|
||||||
|
- Run the server |
||||||
|
|
||||||
|
``` |
||||||
|
> cd GreeterServer |
||||||
|
> dotnet run |
||||||
|
``` |
||||||
|
|
||||||
|
- Run the client |
||||||
|
|
||||||
|
``` |
||||||
|
> cd GreeterClient |
||||||
|
> dotnet run |
||||||
|
``` |
||||||
|
|
||||||
|
Tutorial |
||||||
|
-------- |
||||||
|
|
||||||
|
You can find a more detailed tutorial about Grpc in [gRPC Basics: C#][] |
||||||
|
|
||||||
|
[helloworld.proto]:../../protos/helloworld.proto |
||||||
|
[gRPC Basics: C#]:http://www.grpc.io/docs/tutorials/basic/csharp.html |
@ -1,8 +1,7 @@ |
|||||||
{ |
{ |
||||||
"name": "grpc/grpc-demo", |
"name": "grpc/grpc-demo", |
||||||
"description": "gRPC example for PHP", |
"description": "gRPC example for PHP", |
||||||
"minimum-stability": "dev", |
|
||||||
"require": { |
"require": { |
||||||
"grpc/grpc": "v0.15.2" |
"grpc/grpc": "v1.0.0" |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,6 +1,6 @@ |
|||||||
#gRPC Basics: PHP sample code |
#gRPC Basics: PHP sample code |
||||||
|
|
||||||
The files in this folder are the samples used in [gRPC Basics: PHP][], |
The files in this folder are the samples used in [gRPC Basics: PHP][], |
||||||
a detailed tutorial for using gRPC in Ruby. |
a detailed tutorial for using gRPC in PHP. |
||||||
|
|
||||||
[gRPC Basics: PHP]:http://www.grpc.io/docs/tutorials/basic/php.html |
[gRPC Basics: PHP]:http://www.grpc.io/docs/tutorials/basic/php.html |
||||||
|
@ -1,56 +1 @@ |
|||||||
gRPC in 3 minutes (Python) |
[This code's documentation lives on the grpc.io site.](http://www.grpc.io/docs/quickstart/python.html) |
||||||
======================== |
|
||||||
|
|
||||||
Background |
|
||||||
------------- |
|
||||||
For this sample, we've already generated the server and client stubs from |
|
||||||
[helloworld.proto][] and we'll be using a specific reference platform. |
|
||||||
|
|
||||||
|
|
||||||
Install gRPC: |
|
||||||
```sh |
|
||||||
$ pip install grpcio |
|
||||||
``` |
|
||||||
Or, to install it system wide: |
|
||||||
```sh |
|
||||||
$ sudo pip install grpcio |
|
||||||
``` |
|
||||||
|
|
||||||
If you're on Windows, make sure you installed the `pip.exe` component when you |
|
||||||
installed Python. Invoke as above but with `pip.exe` instead of `pip` (you may |
|
||||||
also need to invoke from a `cmd.exe` ran as administrator): |
|
||||||
```sh |
|
||||||
$ pip.exe install grpcio |
|
||||||
``` |
|
||||||
|
|
||||||
Download the example |
|
||||||
```sh |
|
||||||
$ # Clone the repository to get the example code: |
|
||||||
$ git clone https://github.com/grpc/grpc |
|
||||||
$ # Navigate to the "hello, world" Python example: |
|
||||||
$ cd grpc/examples/python/helloworld |
|
||||||
``` |
|
||||||
|
|
||||||
Try it! |
|
||||||
------- |
|
||||||
|
|
||||||
- Run the server |
|
||||||
|
|
||||||
```sh |
|
||||||
$ python2.7 greeter_server.py & |
|
||||||
``` |
|
||||||
|
|
||||||
- Run the client |
|
||||||
|
|
||||||
```sh |
|
||||||
$ python2.7 greeter_client.py |
|
||||||
``` |
|
||||||
|
|
||||||
Tutorial |
|
||||||
-------- |
|
||||||
|
|
||||||
You can find a more detailed tutorial in [gRPC Basics: Python][] |
|
||||||
|
|
||||||
[helloworld.proto]:../protos/helloworld.proto |
|
||||||
[Install gRPC Python]:../../src/python#installation |
|
||||||
[gRPC Basics: Python]:http://www.grpc.io/docs/tutorials/basic/python.html |
|
||||||
|
@ -1 +1 @@ |
|||||||
[This code's documentation lives on the grpc.io site.](http://www.grpc.io/docs) |
[This code's documentation lives on the grpc.io site.](http://www.grpc.io/docs/quickstart/python.html) |
||||||
|
@ -1 +1,3 @@ |
|||||||
An example showing two stubs sharing a channel and two servicers sharing a server. |
An example showing two stubs sharing a channel and two servicers sharing a server. |
||||||
|
|
||||||
|
More complete documentation lives at [grpc.io](http://www.grpc.io/docs/tutorials/basic/python.html). |
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue