Skip to content

Commit

Permalink
Added support for optional fields in proto3
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Levitskii <[email protected]>
  • Loading branch information
biosvs committed Dec 13, 2023
1 parent ed888ff commit 9ec77e3
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 9ec77e3

Please sign in to comment.