abitofhelp / connect-go-googleapis

This repository contains a client/server solution implementing the classic Greet service using the following technologies: Bazel (bzlmod), Buf, ConnectRPC, Go, GoogleApis, and Protocol Buffers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

connect-go-googleapis

This repository contains a client/server solution implementing the classic Greet service using the following technologies:

  • Bazel
  • Buf
  • ConnectRPC
  • Go
  • GoogleApis
  • Grpc Health
  • Grpc Reflection
  • Protocol Buffers

File Generation

There are three ways to generate the Protocol Buffer and ConnectRPC files:

  1. protoc -I proto --go_out='gen/' --go_opt=paths=source_relative --connect-go_out='gen/' --connect-go_opt=paths=source_relative $(find proto -name '*.proto')

  2. buf generate proto

  3. bazel build

    • bazel build //proto/greet/v1:greetv1_connect_go_proto
      This command will generate the Protocol Buffers & Connect RPC files.
    • bazel build //proto/greet/v1:greetv1_connect_go_proto
      and
      bazel build //proto/greet/v1:greetv1_go_proto
      The first command generates the Protocol Buffer file.
      The second command generates the ConnectRPC file.
      It doesn't generate the Protocol Buffer file unless it has changed.

Build

There are two alternatives to build the solution depending on how you
generated the Protocol Buffer and ConnectRPC files:

  1. Go Build From protoc or buf
    go build ./...

  2. Bazel Build
    bazel build //...

IMPORTANT: If you want to build interchangeably using 'go build' or 'bazel build', the import paths in the generated files must be consistent. Essentially, each path in the plugin's 'out' field must be the root of the importpath & overrideimportpath in the go_proto_library blocks in proto/greet/v1/BUILD.bazel. Here is an example from this repository's code showing proper alignment between the configuration files using a path starting at 'gen'.

proto/greet/v1/greet1connect/BUILD.bazel (redacted to relevant blocks)

alt text

proto/greet/v1/BUILD.bazel (redacted to relevant blocks)

alt text

GreetService Queries

GreetService Health Queries

Resources

About

This repository contains a client/server solution implementing the classic Greet service using the following technologies: Bazel (bzlmod), Buf, ConnectRPC, Go, GoogleApis, and Protocol Buffers.

License:MIT License


Languages

Language:Starlark 77.8%Language:Go 20.8%Language:Shell 1.4%