Parked: Tombstone services before sending updates#50
Open
mihaitodor wants to merge 2 commits intomasterfrom
Open
Parked: Tombstone services before sending updates#50mihaitodor wants to merge 2 commits intomasterfrom
mihaitodor wants to merge 2 commits intomasterfrom
Conversation
Services from expired servers need to be tombstoned before informing the listeners about them.
Use the StateChangedEvent.ChangeEvent.Time to figure out if the current state of the receiver is older than the received event. We can't rely on evt.State.LastChanged for this because, when expiring a server, we get multiple events coming in on UrlListener.eventChannel and each StateChangedEvent created will contain a snapshot of the same state. This will make the receiver process only the first incoming event and drop the rest, because rcvr.CurrentState.LastChanged = evt.State.LastChanged after the first event gets processed.
relistan
reviewed
May 15, 2019
|
|
||
| svcId1 := "deadbeef123" | ||
| service1 := service.Service{ID: svcId1, Hostname: hostname} | ||
| svcId2 := "ecgtheow" |
relistan
reviewed
May 15, 2019
| previousStatus := svc.Status | ||
| state.ServiceChanged(svc, previousStatus, svc.Updated) | ||
| svc.Tombstone() | ||
| state.ServiceChanged(svc, previousStatus, svc.Updated) |
Collaborator
There was a problem hiding this comment.
You know it occurs to me that maybe we ought to be just doing this outside the loop by capturing the initial state and the final state. No one can process those intermediate changes that fast anyway.
Collaborator
There was a problem hiding this comment.
Hmm, I guess if anything relied on svc.Updated that would break them. Maybe there is some middle ground.
relistan
reviewed
May 15, 2019
|
|
||
| func Test_Listen(t *testing.T) { | ||
| Convey("Listen()", t, func() { | ||
| Convey("Listen()", t, func(c C) { |
Collaborator
There was a problem hiding this comment.
I did not know this was a thing. Interesting.
Author
There was a problem hiding this comment.
It's handy for testing inside goroutines, although I still haven't gotten around to fixing this bug: smartystreets/goconvey#477
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.
Services from expired servers need to be tombstoned before informing the listeners about them, I think :)
In
TombstoneOthersServices, we have here a similar call tostate.ServiceChanged, where the services get tombstoned first.LE: There is another problem with missed events due to having a timestamp older than the current state in the receiver, which I tried to fix in 7211a4f, but it's not going to work as is because once the first event is processed by the receiver, the receiver state will contain a timestamp that is newer than all the ChangeEvent.Time of all the other events sent when a server gets expired...