-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parked: Tombstone services before sending updates #50
base: master
Are you sure you want to change the base?
Parked: Tombstone services before sending updates #50
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.
hostname := "grendel" | ||
|
||
svcId1 := "deadbeef123" | ||
service1 := service.Service{ID: svcId1, Hostname: hostname} | ||
svcId2 := "ecgtheow" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
svc.Tombstone() | ||
state.ServiceChanged(svc, previousStatus, svc.Updated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess if anything relied on svc.Updated
that would break them. Maybe there is some middle ground.
@@ -47,36 +50,57 @@ func Test_prepareCookieJar(t *testing.T) { | |||
} | |||
|
|||
func Test_Listen(t *testing.T) { | |||
Convey("Listen()", t, func() { | |||
Convey("Listen()", t, func(c C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know this was a thing. Interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's handy for testing inside goroutines, although I still haven't gotten around to fixing this bug: smartystreets/goconvey#477
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...