The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Yash Tibrewal 41ec08c69a
Update third_party/protobuf to 3.21.4 (#30377)
2 years ago
..
README.md Add Python PSM security example (#26170) 4 years ago
client.py Introduce Python import sorting to our sanity test suite (#26768) 3 years ago
helloworld_pb2.py Update third_party/protobuf to 3.21.4 (#30377) 2 years ago
helloworld_pb2.pyi Update third_party/protobuf to 3.21.4 (#30377) 2 years ago
helloworld_pb2_grpc.py Update third_party/protobuf to 3.21.4 (#30377) 2 years ago
requirements.txt Add Python PSM security example (#26170) 4 years ago
server.py Switch Python xDS Example Server to Listen on IPV4 Only (#27679) (#27758) 3 years ago

README.md

gRPC Hostname Example

The hostname example is a Hello World server whose response includes its hostname. It also supports health and reflection services. This makes it a good server to test infrastructure, like load balancing. This example depends on a gRPC version of 1.28.1 or newer.

Run the Server

  1. Navigate to this directory:
cd grpc/examples/python/xds
  1. Run the server
virtualenv venv -p python3
source venv/bin/activate
pip install -r requirements.txt
python server.py

Run the Client

  1. Set up xDS configuration.

After configuring your xDS server to track the gRPC server we just started, create a bootstrap file as desribed in gRFC A27:

{
  xds_servers": [
    {
      "server_uri": <string containing URI of xds server>,
      "channel_creds": [
        {
          "type": <string containing channel cred type>,
          "config": <JSON object containing config for the type>
        }
      ]
    }
  ],
  "node": <JSON form of Node proto>
}
  1. Point the GRPC_XDS_BOOTSTRAP environment variable at the bootstrap file:
export GRPC_XDS_BOOTSTRAP=/etc/xds-bootstrap.json
  1. Run the client:
python client.py xds:///my-backend

Verifying Configuration with a CLI Tool

Alternatively, grpcurl can be used to verify your server. If you don't have it, install grpcurl. This will allow you to manually test the service.

Be sure to set up the bootstrap file and GRPC_XDS_BOOTSTRAP as in the previous section.

  1. Verify the server's application-layer service:
> grpcurl --plaintext -d '{"name": "you"}' localhost:50051
{
  "message": "Hello you from rbell.svl.corp.google.com!"
}
  1. Verify that all services are available via reflection:
> grpcurl --plaintext localhost:50051 list
grpc.health.v1.Health
grpc.reflection.v1alpha.ServerReflection
helloworld.Greeter
  1. Verify that all services are reporting healthy:
> grpcurl --plaintext -d '{"service": "helloworld.Greeter"}' localhost:50051
grpc.health.v1.Health/Check
{
  "status": "SERVING"
}

> grpcurl --plaintext -d '{"service": ""}' localhost:50051
grpc.health.v1.Health/Check
{
  "status": "SERVING"
}

Running with Proxyless Security

Run the Server with Secure Credentials

Add the --secure true flag to the invocation outlined above.

python server.py --secure true

Run the Client with Secure Credentials

Add the --secure true flag to the invocation outlined above.

  1. Run the client:
python client.py xds:///my-backend --secure true