proto3

golang protobuf remove omitempty tag from generated json tags

青春壹個敷衍的年華 提交于 2020-12-28 07:04:45
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

golang protobuf remove omitempty tag from generated json tags

浪子不回头ぞ 提交于 2020-12-28 06:56:28
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

golang protobuf remove omitempty tag from generated json tags

烂漫一生 提交于 2020-12-28 06:50:27
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

golang protobuf remove omitempty tag from generated json tags

我怕爱的太早我们不能终老 提交于 2020-12-28 06:47:31
问题 I am using google grpc with a json proxy. for some reason i need to remove the omitempty tags from the struct generated in the *.pb.go files. if i have a proto message like this message Status { int32 code = 1; string message = 2; } The generated struct looks like this type Status struct { Code int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } But My need is to remove the omitempty tag from the

C# Google.ProtocolBuffers Deserialization Method (proto3)

眉间皱痕 提交于 2020-01-03 15:34:11
问题 I have recently upgraded my code base (Java, C++ and C#) to use proto3. In the case of C# this has involved over 2000 changes to the code. This is mostly semantic and all good, but there is one issue I can't seem to fathom; serialization/deserialization. I have the following amended method to desearialize my IMessage types (the code to do this in proto2 is commented), this is the code that is show in the examples within the GitHub repository... public static T ToObject<T>(this byte[] buf)

gRPC / Protobuf interface versioning

只愿长相守 提交于 2019-12-30 04:03:31
问题 Let's say we use gRCP/Protobuf to connect many application. Those application are developped and released at their own team, with their own speed. Over time there will be different version of the the same app (e.g. desktop apps install on user PCs) that use different version on defined interface. While Protobuf is meant to allow backward compatibility, is there a way to know what version of interface is running at different points? The simplest implementation is to have interface version

Exception handling in gRPC

人走茶凉 提交于 2019-12-22 05:48:15
问题 I have a server written in Java and client written in PHP. How can client catch exception from server if anything goes wrong? I can't find anything about exception handling in gRPC documentation. Thank you! 回答1: For handled exceptions, call responseObserver.onError() . If you pass in a StatusRuntimeException or StatusException (generally created via status.asRuntimeException() ) the status code and description will be communicated to the client. Unhandled exceptions within a callback will

Reading comments from .proto files using a Protocol Buffers descriptor object

亡梦爱人 提交于 2019-12-13 13:15:39
问题 I am currently revisiting a project using Google Protocol Buffers. In the project I want to make use of the features Descriptors and Reflection of Protocol Buffers. The official documentation states that the comments of .proto files can be read: With the function DebugStringWithOptions(), called on a message or descriptor. With the function GetSourceLocation(), called on a descriptor. I am unable to retrieve comments, so I think I am doing something completely wrong or that feature isn't

Proto3 setting value equal to default is not recognised in runtime

一世执手 提交于 2019-12-10 10:13:46
问题 Proto3 is not as strict as Proto2 , and there are no required or optional fields, there are no custom default values. Given the following definition... message Order { enum Side { BID = 0; ASK = 1; } int64 time = 1; double price = 2; double volume = 3; Side side = 4; } There are default values for any of those fields, after all now there are no rules of what you must or must not provide before you .build() your object. So the default for time is 0 , price is 0.0 and side is BID , if you print

Protobuf backward compatibility and proto3 vs proto2

风格不统一 提交于 2019-12-08 00:11:46
问题 One of selling points of Protobuf was backward compatibility, i.e. developers can evolve format, and older clients can still use it. Now with new Protobuf version called proto3, the IDL language itself is not compatible as such things as options , required where dropped, new syntax for enuns, no extention. Does it mean that using proto3 there's no way to produce binary that older proto2 would read/understand also? It is like you have to continue to use proto2. If you start using proto3, you