protoc-gen-go-restate

command
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 9 Imported by: 0

README

protoc-gen-go-grpc

This tool generates Go language bindings of services in protobuf definition files for Restate.

An example of their use can be found in examples/codegen

Usage

Via protoc:

go install github.com/restatedev/sdk-go/protoc-gen-go-restate@latest
protoc --go_out=. --go_opt=paths=source_relative \
--go-restate_out=. --go-restate_opt=paths=source_relative service.proto

Via buf:

# buf.gen.yaml
plugins:
  - remote: buf.build/protocolbuffers/go:v1.34.2
    out: .
    opt: paths=source_relative
  - local: protoc-gen-go-restate
    out: .
    opt: paths=source_relative

Providing options

This protoc plugin supports the service and method extensions defined in proto/dev/restate/sdk/go.proto. You will need to use these extensions to define virtual objects in proto.

You can import the extensions with the statement import "dev/restate/sdk/go.proto";. Protoc will expect an equivalent directory structure containing the go.proto file either locally, or under any of the paths provided with --proto_path. It may be easier to use buf to import:

# buf.yaml
version: v2
deps:
  - buf.build/restatedev/sdk-go

Upgrading from pre-v0.14

This generator used to create Restate services and methods using the Go names (eg Greeter/SayHello) instead of the fully qualified protobuf names (eg helloworld.Greeter/SayHello). This was changed to make this package more compatible with gRPC. To maintain the old behaviour, pass --go-restate_opt=use_go_service_names=true to protoc. With buf:

...
  - local: protoc-gen-go-restate
    out: .
    opt:
      - paths=source_relative
      - use_go_service_names=true

Documentation

Overview

protoc-gen-go-restate is a plugin for the Google protocol buffer compiler to generate Restate servers and clients. Install it by building this program and making it accessible within your PATH with the name:

protoc-gen-go-restate

The 'go-restate' suffix becomes part of the argument for the protocol compiler, such that it can be invoked as:

protoc --go-restate_out=. path/to/file.proto

This generates Restate service definitions for the protocol buffer defined by file.proto. With that input, the output will be written to:

path/to/file_restate.pb.go

Lots of code copied from protoc-gen-go-grpc: https://github.com/grpc/grpc-go/tree/master/cmd/protoc-gen-go-grpc ! License Apache-2.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL