MCPcopy
hub / github.com/grpc/grpc-go / loadFileDescDynamic

Function loadFileDescDynamic

reflection/test/serverreflection_test.go:89–113  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

87}
88
89func loadFileDescDynamic(b []byte) (*descriptorpb.FileDescriptorProto, protoreflect.FileDescriptor, []byte) {
90 m := new(descriptorpb.FileDescriptorProto)
91 if err := proto.Unmarshal(b, m); err != nil {
92 panic("failed to unmarshal dynamic proto raw descriptor")
93 }
94
95 fd, err := protodesc.NewFile(m, nil)
96 if err != nil {
97 panic(err)
98 }
99
100 err = protoregistry.GlobalFiles.RegisterFile(fd)
101 if err != nil {
102 panic(err)
103 }
104
105 for i := 0; i < fd.Messages().Len(); i++ {
106 m := fd.Messages().Get(i)
107 if err := protoregistry.GlobalTypes.RegisterMessage(dynamicpb.NewMessageType(m)); err != nil {
108 panic(err)
109 }
110 }
111
112 return m, fd, b
113}
114
115func init() {
116 _, fdTestByte = loadFileDesc("reflection/grpc_testing/test.proto")

Callers 1

initFunction · 0.85

Calls 3

UnmarshalMethod · 0.65
LenMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected