Add service removed events to Browse#281
Open
backkem wants to merge 2 commits into
Open
Conversation
Emitted instances dropped out of cache monitoring: their records expired silently and a departed service stayed in the consumer's view forever. Browse now keeps emitted instances monitored (refresh per RFC 6762 §5.2) and emits ServiceRemoved when the instance PTR is goodbye'd (§10.1) or expires unrefreshed. Returning instances are reported as fresh adds. API: ServiceEvent.Type, OnServiceEvent (OnServiceDiscovered now a deprecated alias), WithServiceEventTypes option. The legacy Server constructor delivers only ServiceAdded so code written before removal events existed never sees the new event type.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #281 +/- ##
==========================================
+ Coverage 84.11% 85.09% +0.97%
==========================================
Files 8 8
Lines 1970 2019 +49
==========================================
+ Hits 1657 1718 +61
+ Misses 202 195 -7
+ Partials 111 106 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
collectEvents and feedInstance lived in client_test.go (!js) but were referenced from refresh_test.go, which has no js constraint and is compiled for the WASM test target.
Member
Author
|
@jwetzell we can also consider adding an |
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.
Browse so far only ever said hello: an instance was reported once, its records silently fell out of cache monitoring, and a service that left the network stayed in the consumer's view forever. Any real browse UI or discovery loop needs the goodbye too.
ServiceEvent.TypedistinguishesServiceAddedfromServiceRemoved, fired on goodbye (RFC 6762 §10.1) or unrefreshed expiry of the instance PTR. Returning instances are re-reported as fresh adds.WithRecordTypes/WithCacheRefreshdefaults: newWithServiceEventTypesoption, and legacyServer()defaults toServiceAddedonly, so pre-existing code never sees the new event type.compat_test.gopins the whole legacy contract.OnServiceEventreplacesOnServiceDiscovered(deprecated alias kept): the stream carries lifecycle events now, not just discoveries.Design: one removal pathway. Goodbyes are retained 1s in the cache and both goodbye and natural expiry surface through
sweep(), which now returns what it removed. Removal is driven by the instance PTR only; cache-flush rdata replacement (§10.2) and cap evictions don't emit events. Also fixes a phantom pending instance created by goodbye PTRs for unknown instances.Part of #253 (Phase 5).