feat(watcher): add addField() for dynamic field registration#101
Merged
Conversation
ConfigWatcher.field() was one-shot: calling it after start() threw. addField() fills that gap — it works both before and after start(). When called post-start it fetches a targeted GetConfig snapshot to seed the new field's initial value, cancels the current Subscribe stream, and re-opens it with the full updated field list. Internally, loadSnapshot() is refactored into a private loadSnapshotForFields(paths) helper so both the full reconnect path and the targeted addField path share the same logic. Closes #70 Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConfigWatcher.field()was one-shot: the field list was frozen atstart()time, making it impossible to subscribe to new fields in a running watcher.addField()lifts this constraint by loading the new field's initial value from a targeted GetConfig snapshot and re-opening the Subscribe stream with the updated field list.loadSnapshot()is refactored into a privateloadSnapshotForFields(paths)helper shared by both the full reconnect path and the new targetedaddFieldpath.Test plan
addField()beforestart()— field is included and populated whenstart()runs.addField()afterstart()— loads initial value, cancels current stream, re-subscribes with updated field list.addField()afterstop()throwsDecreeError.Closes #70