[dynamic control] Add priority ordering to sources#2970
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an explicit source-priority concept to dynamic-control policy sources to support spec-required precedence when multiple sources provide the same policy ID (OpAMP > HTTP > file).
Changes:
- Added a numeric
priorityfield toSourceKindwith spec-aligned values for OPAMP/HTTP/FILE (and a low-priority default for CUSTOM). - Exposed priority via
priority()and addedhasHigherPriorityThan(SourceKind other)for comparisons.
LikeTheSalad
left a comment
There was a problem hiding this comment.
Not sure if relevant, but this makes me wonder what would happen if 2 sources have the same priority? Or are there going to be mechanisms before reaching this part that prevent that from happening?
Nothing prevents the same source sending the same policy with two different values at the same time. For example sending sampling rate at 50% and 10% at the same time. The spec says these should be "merged". Merged here could only mean dropping one. Which one is up to the implementation. In the full data structure, there would be a timestamp in the policy, and you could choose to keep the latter. But even the timestamps could be the same. The implementation currently just chooses one. Specifically the current implementation keeps the first one read from the data structure. |
Description:
The spec requires opamp > http > file priority of policies so if mergeable policies are received by more than one source in an update, the highest priority policy is retained and the others dropped
Existing Issue(s):
#2868
Testing:
added
Documentation:
n/a
Outstanding items:
Still to implement
Also #2868