Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 1.99 KB

README.md

File metadata and controls

75 lines (51 loc) · 1.99 KB

Bazel demo

Golang based demo project, relying on Bazel.

This project provides the following components:

  • protobuf definition located in the proto folder
  • golang backend application acting as gRPC server (using Bazel autogenerated stubs)
  • golang client application to be able to test interactions with the server (using Bazel autogenerated stubs)
  • golang gRPC-gateway acting as a REST - gRPC reverse proxy (using Bazel autogenerated stubs)
  • open api documentation for the REST interface of the gRPC-gateway (autogenerated by Bazel)

Table of contents

Installation

You first need to install Bazel on your machine.

Then, you can build the project using:

bazel build //...

Usage

  • To run the go gRPC server, located in the backend folder (will listen on :50051):
bazel run //backend
  • To start the go gRPC client, located in the client folder:
bazel run //client
  • To start the go gRPC gateway, located in the gateway folder (will listen on :8888):
bazel run //gateway

Note: you can check the autogenerated openapi documentation to know how to use the gateway.

Commands

  • Bazel (build & test tool)
#list dependency graph targets
bazel query //... --output label_kind | sort | column -t 

#build all targets
bazel build //... 

#buld target XXX 
bazel build //XXX 

#run target XXX 
bazel run //XXX 
  • Gazelle (BUILD file generator)
#build / refresh all BUILD files of the repository tree
bazel run //:gazelle 

#build / refresh using go.mod
bazel run //:gazelle -- update-repos -from_file=go.mod