Giter Site home page Giter Site logo

grpc-java-bazel-example's Introduction

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

git clone [email protected]:kouky/grpc-java-bazel-example.git
cd grpc-java-bazel-example

Run Hello World gRPC Application

Compile all the bazel targets

bazel build //...

Run the server

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

In another terminal, run the client

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

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

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

Run RouteGuide gRPC Application

Compile all the bazel targets

bazel build //...

Run the server

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

In another terminal, run the client

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

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

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

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.

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

grpc-java-bazel-example's People

Contributors

kouky avatar

Watchers

 avatar  avatar

grpc-java-bazel-example's Issues

Upgrade version of dependencies

Current protobuf and related artifact versions in dependencies.yml are defined as "1.14.0". These can be upgraded to latest version (1.18.0 as of this issue)

bazel build fails with error

grpc-java-bazel-example $ bazel build //...     
INFO: Invocation ID: 86dbbe4c-d4e8-46c6-a408-773079bc0112
ERROR: /private/var/tmp/_bazel_jkurapati/de64285080fc73ca555b84cca93e12ec/external/com_google_protobuf/BUILD:573:1: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_jkurapati/de64285080fc73ca555b84cca93e12ec/external/com_google_protobuf/BUILD", line 573
		internal_gen_well_known_protos_java(srcs = WELL_KNOWN_PROTOS)
	File "/private/var/tmp/_bazel_jkurapati/de64285080fc73ca555b84cca93e12ec/external/com_google_protobuf/protobuf.bzl", line 269, in internal_gen_well_known_protos_java
		Label(("%s//protobuf_java" % REPOSITOR...))
	File "/private/var/tmp/_bazel_jkurapati/de64285080fc73ca555b84cca93e12ec/external/com_google_protobuf/protobuf.bzl", line 269, in Label
		REPOSITORY_NAME
The value 'REPOSITORY_NAME' has been removed in favor of 'repository_name()', please use the latter (https://docs.bazel.build/versions/master/skylark/lib/native.html#repository_name). You can temporarily allow the old name by using --incompatible_package_name_is_a_function=false
ERROR: /private/var/tmp/_bazel_jkurapati/de64285080fc73ca555b84cca93e12ec/external/com_google_protobuf/BUILD:355:1: Target '@com_google_protobuf//:android' contains an error and its package is in error and referenced by '@com_google_protobuf//:protoc'
ERROR: /private/var/tmp/_bazel_jkurapati/de64285080fc73ca555b84cca93e12ec/external/com_google_protobuf/BUILD:355:1: Target '@com_google_protobuf//:msvc' contains an error and its package is in error and referenced by '@com_google_protobuf//:protoc'
ERROR: /Users/jkurapati/Documents/working/workspace/grpc-java-bazel-example/src/main/proto/BUILD:16:1: every rule of type _gensource implicitly depends upon the target '@com_google_protobuf//:protoc', but this target could not be found because of: Target '@com_google_protobuf//:protoc' contains an error and its package is in error
ERROR: Analysis of target '//src/main/proto:helloworld_java_grpc__do_not_reference__srcjar' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.275s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 3 targets configured)
    currently loading: @bazel_tools//tools/jdk
โžœ  grpc-java-bazel-example $

My version of bazel

Build label: 0.21.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Dec 19 12:57:09 2018 (1545224229)
Build timestamp: 1545224229
Build timestamp as int: 1545224229

Please let me know if you want any more info

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.