I am reading UDP stream using java and proto buf which supports extension.
At any given time i can get three different type of data which corresponds to three different types of proto files.
I am using
registry.add(CpuUtilization.cpuUtilExt);
registry.add(NpuUtilization.npuExt);
registry.add(Optics.opticsExt);
All of three proto files are using below mention syntax for extension
extend NetworksSensors {
optional PFEHeapInfo pfeHeapInfoExt = 1;
}
extend NetworksSensors {
optional NpuUtilization npuExt = 2;
}
extend NetworksSensors {
optional CpuUtilization cpuUtilExt = 3;
}
What i am doing is create three separate methods and process the data for each type of sensor based on the value inside header field.
Is there a way i can decide which method to call based on extension data that is coming?
May be some field from descriptor can help, but i don't know to use that. Any idea?