Skip to content

Commit

Permalink
runtime: rewrite fieldmask logic with protoreflect
Browse files Browse the repository at this point in the history
Replace the use of the descriptorpb when we can use reflection
instead. Also add more thorough test and support repeated fields.
  • Loading branch information
johanbrandhorst committed May 14, 2020
1 parent 43ced79 commit 52174f2
Show file tree
Hide file tree
Showing 29 changed files with 1,781 additions and 687 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ HELLOWORLD_GWSRCS=$(HELLOWORLD:.proto=.pb.gw.go)

RUNTIME_TEST_PROTO=runtime/internal/examplepb/example.proto \
runtime/internal/examplepb/proto2.proto \
runtime/internal/examplepb/proto3.proto
runtime/internal/examplepb/proto3.proto \
runtime/internal/examplepb/non_standard_names.proto
RUNTIME_TEST_SRCS=$(RUNTIME_TEST_PROTO:.proto=.pb.go)

EXAMPLE_CLIENT_DIR=examples/internal/clients
Expand Down
1 change: 0 additions & 1 deletion examples/internal/helloworld/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ go_library(
deps = [
"//internal/utilities:go_default_library",
"//runtime:go_default_library",
"@com_github_golang_protobuf//descriptor:go_default_library_gen",
"@com_github_golang_protobuf//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
Expand Down
2 changes: 0 additions & 2 deletions examples/internal/helloworld/helloworld.pb.gw.go

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

2 changes: 0 additions & 2 deletions examples/internal/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go_test(
name = "go_default_test",
srcs = [
"client_test.go",
"fieldmask_test.go",
"integration_test.go",
"main_test.go",
],
Expand All @@ -19,7 +18,6 @@ go_test(
"//examples/internal/server:go_default_library",
"//runtime:go_default_library",
"@com_github_golang_glog//:go_default_library",
"@com_github_golang_protobuf//descriptor:go_default_library_gen",
"@com_github_golang_protobuf//jsonpb:go_default_library_gen",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_google_go_cmp//cmp:go_default_library",
Expand Down
183 changes: 0 additions & 183 deletions examples/internal/integration/fieldmask_test.go

This file was deleted.

38 changes: 25 additions & 13 deletions examples/internal/proto/examplepb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ proto_library(
"echo_service.proto",
"flow_combination.proto",
"generated_output.proto",
"non_standard_names.proto",
"response_body_service.proto",
"stream.proto",
"unannotated_echo_service.proto",
Expand All @@ -56,36 +55,49 @@ proto_library(
go_proto_library(
name = "examplepb_go_proto",
compilers = [
"@io_bazel_rules_go//proto:go_grpc",
"//protoc-gen-grpc-gateway:go_gen_grpc_gateway", # keep
],
importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb",
proto = ":examplepb_proto",
deps = [
"//examples/internal/proto/pathenum:go_default_library",
"//examples/internal/proto/sub:go_default_library",
"//examples/internal/proto/sub2:go_default_library",
"//protoc-gen-swagger/options:go_default_library",
"@com_github_golang_protobuf//descriptor:go_default_library_gen", # keep
"@go_googleapis//google/api:annotations_go_proto",
"@go_googleapis//google/api:httpbody_go_proto",
],
)

go_library(
name = "go_default_library",
srcs = ["unannotated_echo_service.pb.gw.go"],
embed = [":examplepb_go_proto"],
srcs = [
"a_bit_of_everything.pb.go",
"echo_service.pb.go",
"flow_combination.pb.go",
"non_standard_names.pb.go",
"response_body_service.pb.go",
"stream.pb.go",
"unannotated_echo_service.pb.go",
"unannotated_echo_service.pb.gw.go",
"use_go_template.pb.go",
"wrappers.pb.go",
],
importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb",
deps = [
"//examples/internal/proto/pathenum:go_default_library",
"//examples/internal/proto/sub:go_default_library",
"//examples/internal/proto/sub2:go_default_library",
"//internal/utilities:go_default_library",
"//protoc-gen-swagger/options:go_default_library",
"//runtime:go_default_library",
"@com_github_golang_protobuf//descriptor:go_default_library_gen",
"@com_github_golang_protobuf//proto:go_default_library",
"@go_googleapis//google/api:annotations_go_proto",
"@go_googleapis//google/api:httpbody_go_proto",
"@io_bazel_rules_go//proto/wkt:duration_go_proto",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@io_bazel_rules_go//proto/wkt:field_mask_go_proto",
"@io_bazel_rules_go//proto/wkt:timestamp_go_proto",
"@io_bazel_rules_go//proto/wkt:wrappers_go_proto",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//grpclog:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library",
"@org_golang_google_protobuf//runtime/protoimpl:go_default_library",
],
)

Expand Down

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

2 changes: 0 additions & 2 deletions examples/internal/proto/examplepb/echo_service.pb.gw.go

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

2 changes: 0 additions & 2 deletions examples/internal/proto/examplepb/flow_combination.pb.gw.go

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

Loading

0 comments on commit 52174f2

Please sign in to comment.