Files
backstage/proto/README.md
T
2020-03-05 16:28:14 +01:00

1.7 KiB

Backstage proto

Collection of all Backstage protobuf definitions.

Usage

Prodobuf definitions are managed with Prototool.

Installing Dependencies

Prototool

See installation instructions. On MacOS you can use brew install prototool.

Go

You will need to have Go installed, along with a properly set up GOPATH and $GOPATH/bin added to your PATH, follow the instructions here.

protoc-gen-go

This will enable code generation for Go. You will need to have protoc-gen-go available in your path. You can find out more information here: https://github.com/golang/protobuf

$ go get -u github.com/golang/protobuf/protoc-gen-go
$ protoc-gen-go # should now be available in your path providing you GOPATH + GOBIN paths are setup correctly.

protoc-gen-grpc-web

This will enable code generation for interacting with gRPC-Web.

Installation instructions are found at https://github.com/grpc/grpc-web#code-generator-plugin

Generating Code

To generate the Protobuf definitions in Go and TypeScript, run the following command inside the proto/ directory with Prototool:

$ prototool generate

This will generate the respective "generated" files in the backend/proto folder.

All generated code related to Protocol Buffers should be checked in to the repository.

Code Examples

Import using Go

This is what you'll need to use for development in any of the backend services.

package spotify.backstage.identity.v1;

func main() {
  identityv1.NewInventoryClient(nil)
}