Skip to content

Commit

Permalink
Merge pull request #2237 from yarpc/use-plugin-v2
Browse files Browse the repository at this point in the history
Added support for optional fields in proto3
  • Loading branch information
biosvs authored Dec 14, 2023
2 parents ed888ff + 9ec77e3 commit d9173b0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- tchannel: optional transport-level config to allow reusing a buffer for reading a tchannel response body.
- grpc: returned outbound response body is no longer writable.
- Fixed panic when error details list contains message that cannot be unmarshalled.
- Plugin v2: use v2 of internal libraries; indicate "optional" field support in the plugin response.

## [1.70.4] - 2023-08-31
- logging: fix logged error in observability middleware when fields of transport.Request is in the tagsBlocklist
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion encoding/protobuf/protoc-gen-yarpc-go-v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"os"

"go.uber.org/yarpc/encoding/protobuf/protoc-gen-yarpc-go-v2/internal/lib"
"go.uber.org/yarpc/internal/protoplugin"
protoplugin "go.uber.org/yarpc/internal/protoplugin-v2"
)

func main() {
Expand Down
6 changes: 5 additions & 1 deletion internal/protoplugin-v2/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/golang/protobuf/protoc-gen-go/plugin"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/pluginpb"
)

type runner struct {
Expand Down Expand Up @@ -104,7 +105,10 @@ func (r *runner) Run(request *plugin_go.CodeGeneratorRequest) *plugin_go.CodeGen
}

func newResponseFiles(files []*plugin_go.CodeGeneratorResponse_File) *plugin_go.CodeGeneratorResponse {
return &plugin_go.CodeGeneratorResponse{File: files}
return &plugin_go.CodeGeneratorResponse{
File: files,
SupportedFeatures: proto.Uint64(uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)),
}
}

func newResponseError(err error) *plugin_go.CodeGeneratorResponse {
Expand Down

0 comments on commit d9173b0

Please sign in to comment.