openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
286 stars 107 forks source link

YANG => protobuf => gNMI notification #744

Closed babuveld closed 2 years ago

babuveld commented 2 years ago

Am considering below approach. Please let me know if its feasible with ygot. I think producer side of things should be possible to do, however consumer side am not sure if its possible. I see protomap matches my expectation, however I don't see much examples to give a try. Can you please confirm and provide a possible example for protomap usage.

Producer:

YANG -> Protobuf (generate proto using ygot and encode using c++) -> Serialize -> Stream to consumer.

Consumer:

case 1: Deserialize -> Protobuf -> gNMI notification. case 2: Deserialize -> Protobuf -> EmitJson.

wenovus commented 2 years ago

Generally we use Go bindings (i.e. ygot-generated GoStructs) since it's easier to manipulate configuration in code than generated protobuf code. There is a rich set of utilities in ygot for marshalling/unmarshalling to/from the GoStructs to gNMI notifications.

For an example using Go bindings, see https://github.com/openconfig/ygot/tree/master/demo/gnmi_telemetry

I believe protomap does not support converting from protobuf binding -> gNMI Notifications yet, so the Go binding approach is definitely preferred right now.

babuveld commented 2 years ago

Thanks for the quick response.