You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the API protobuf and gRPC, I've noticed that the protobuf definition file makes heavy use of the google.protobuf.Any type and then there are comments in the protobuf file saying which type you need to pack to actually send across the wire. To me, this seems like a perfect use case for the Oneof message type, but full disclosure, I'm still very inexperienced with protobuf and auto-generated clients. Is this intended behavior and a conscious choice, and if so, is there any information on why this path was chosen? One of the side-effects of using the Any type seems to be that you can't merge or copy objects into an existing object, at least with python generated code. For example, when creating a Path message to send in an AddPathRequest for the AddPath RPC, you have to generate the objects and pack them, then assemble the final Path message. If you don't pack and just use the object itself, you'll get an error. For example:
This may not seem like a big deal (and it's not a huge issue) but it seems to ignore a lot of the reasons for using protobufs (specifically around type safety) and it makes it a bit of a pain to modify an object at any point when you're trying to construct payloads.
To me, it seems like converting the API protobuf from the current state of:
messagePath {
// One of the following defined in "api/attribute.proto":// - IPAddressPrefix// - LabeledIPAddressPrefix// - EncapsulationNLRI// - VPLSNLRI// - EVPNEthernetAutoDiscoveryRoute// - EVPNMACIPAdvertisementRoute// - EVPNInclusiveMulticastEthernetTagRoute// - EVPNEthernetSegmentRoute// - EVPNIPPrefixRoute// - EVPNIPMSIRoute// - LabeledVPNIPAddressPrefix// - RouteTargetMembershipNLRI// - FlowSpecNLRI// - VPNFlowSpecNLRI// - OpaqueNLRI// - LsAddrPrefix// - SRPolicyNLRI// - MUPInterworkSegmentDiscoveryRoute// - MUPDirectSegmentDiscoveryRoute// - MUPType1SessionTransformedRoute// - MUPType2SessionTransformedRoutegoogle.protobuf.Anynlri=1;
}
Hello!
When using the API protobuf and gRPC, I've noticed that the protobuf definition file makes heavy use of the
google.protobuf.Any
type and then there are comments in the protobuf file saying which type you need to pack to actually send across the wire. To me, this seems like a perfect use case for theOneof
message type, but full disclosure, I'm still very inexperienced with protobuf and auto-generated clients. Is this intended behavior and a conscious choice, and if so, is there any information on why this path was chosen? One of the side-effects of using theAny
type seems to be that you can't merge or copy objects into an existing object, at least with python generated code. For example, when creating aPath
message to send in anAddPathRequest
for theAddPath
RPC, you have to generate the objects and pack them, then assemble the finalPath
message. If you don't pack and just use the object itself, you'll get an error. For example:Instead, as shown in the demo documentation, you have to create an empty
Any
object and then pack that with the appropriate GoBGP object, like so:This may not seem like a big deal (and it's not a huge issue) but it seems to ignore a lot of the reasons for using protobufs (specifically around type safety) and it makes it a bit of a pain to modify an object at any point when you're trying to construct payloads.
To me, it seems like converting the API protobuf from the current state of:
Into something like:
Would be beneficial, as then we could create complicated paths and use the
MergeFrom
andCopyFrom
functions directly.Thanks for reading and please let me know if you have any questions (or if I have completely misunderstood how all of this works!)
The text was updated successfully, but these errors were encountered: