forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proto: add functionality to marshal protobuf binary from file descriptor
Part of cockroachdb#47534 Cockroachdb cannot currently marshal a protobuf binary into JSON based on a provided FileDescriptor. The newest version of the `google.golang.org/protobuf` package allows for this functionality. gogo/protobuf does not. Since cockroachdb uses gogo/protobuf for its better performance, I imported `google.golang.org/protobuf` under an alias. Using that libary, I created `NewJSONMessageFromFileDescriptorn` to take a protobuf binary and a FileDescriptorand return JSON. To handle linting errors, temporary wrapper functions `TODOMarshal` and `TODOUnmarshal`; these will need to be renamed if this workaround is acceptable Release note: none
- Loading branch information
1 parent
da553e3
commit 0fbde84
Showing
9 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
|
||
proto_library( | ||
name = "gprototest_proto", | ||
srcs = ["gprototest.proto"], | ||
strip_import_prefix = "/pkg", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_proto_library( | ||
name = "gprototest_go_proto", | ||
compilers = ["@io_bazel_rules_go//proto:go_proto"], #keep | ||
importpath = "github.com/cockroachdb/cockroach/pkg/sql/protoreflect/gprototest", | ||
proto = ":gprototest_proto", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_library( | ||
name = "gprototest", | ||
# srcs = ["wrap.go"], | ||
embed = [":gprototest_go_proto"], # keep | ||
importpath = "github.com/cockroachdb/cockroach/pkg/sql/protoreflect/gprototest", | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
syntax = "proto3"; | ||
package cockroach.sql.gprototest; | ||
option go_package = "github.com/cockroachdb/cockroach/pkg/sql/protoreflect/gprototest"; | ||
|
||
message Inner { | ||
string value = 1; | ||
} | ||
|
||
message Outer { | ||
string value = 1; | ||
Inner inner = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters