项目作者: kouky

项目描述 :
gRPC Java Example using Bazel
高级语言: Java
项目地址: git://github.com/kouky/grpc-java-bazel-example.git
创建时间: 2018-08-26T11:35:24Z
项目社区:https://github.com/kouky/grpc-java-bazel-example

开源协议:Apache License 2.0

下载


gRPC Java Bazel Examples

This repository includes examples of gRPC Java applications built with Bazel. It’s meant as a supplement to the official gRPC Java quick start guide and tutorial.

Before you begin

Clone this repo

  1. git clone git@github.com:kouky/grpc-java-bazel-example.git
  2. cd grpc-java-bazel-example

Run Hello World gRPC Application

Compile all the bazel targets

  1. bazel build //...

Run the server

  1. bazel-bin/src/main/java/org/kouky/helloworld/server/helloworld_server

In another terminal, run the client

  1. bazel-bin/src/main/java/org/kouky/helloworld/client/helloworld_client

You should see the following output as the client talks to the server.

  1. Aug 26, 2018 9:39:49 PM org.kouky.helloworld.client.HelloWorldClient greet
  2. INFO: Will try to greet world ...
  3. Aug 26, 2018 9:39:49 PM org.kouky.helloworld.client.HelloWorldClient greet
  4. INFO: Greeting: Hello world
  5. Aug 26, 2018 9:39:49 PM org.kouky.helloworld.client.HelloWorldClient greet
  6. INFO: Greeting: Hello again world

Run RouteGuide gRPC Application

Compile all the bazel targets

  1. bazel build //...

Run the server

  1. bazel-bin/src/main/java/org/kouky/routeguide/server/routeguide_server

In another terminal, run the client

  1. bazel-bin/src/main/java/org/kouky/routeguide/client/routeguide_client

You should see the following output as the client talks to the server.

  1. Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
  2. INFO: *** GetFeature: lat=409,146,138 lon=-746,188,906
  3. Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
  4. INFO: Found feature called "Berkshire Valley Management Area Trail, Jefferson, NJ, USA" at 40.915, -74.619
  5. Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
  6. INFO: *** GetFeature: lat=0 lon=0
  7. Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
  8. INFO: Found no feature at 0, 0
  9. Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
  10. INFO: *** ListFeatures: lowLat=400,000,000 lowLon=-750,000,000 hiLat=420,000,000 hiLon=-730,000,000
  11. Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
  12. INFO: Result #1: name: "Patriots Path, Mendham, NJ 07945, USA"
  13. location {
  14. latitude: 407838351
  15. longitude: -746143763
  16. }

3rdParty Dependencies

Third party dependencies are specified in dependencies.yaml and generated by bazel-deps.

To regenerate 3rdparty dependencies clone the bazel-deps repo, change directory into it, and run the following.

  1. bazel run //:parse -- generate -r /path/to/grpc-java-bazel-example -s 3rdparty/workspace.bzl -d dependencies.yaml