-
Notifications
You must be signed in to change notification settings - Fork 53
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
Schedule updates to the set of instances registered with a VIP address #55
Merged
Conversation
This file contains 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
Synchronously retrieve the instances registered with a given secure or insecure VIP address, optionally filtering and shuffling them too.
d692280
to
6a12f2d
Compare
This was referenced Dec 9, 2016
When you address comments in #54 This LGTM. Great job, good tests as well. |
Compare the current filterInstances function against the following simpler version: func filterInstancesSimply(instances []*Instance, pred func(*Instance) bool) []*Instance { result := make([]*Instance, 0, len(instances)) for _, instance := range instances { if pred(instance) { result = append(result, instance) } } return result } The following results compare the simpler version to the current version. The test names indicate a run length of instances with a status denoted by the arrows (up or down), followed by the filtering predicate: name criteria ==== ======== all retain all instances; drop none none drop all instances; retain non up retain instances with status "UP"; drop others A negative delta indicates that the current version finishes faster than the simpler version. % benchstat -delta-test none simple.txt fancy.txt name old time/op new time/op delta FilterInstances/1↑/all-8 35.4ns ± 0% 6.5ns ± 0% -81.64% FilterInstances/1↑/none-8 34.1ns ± 0% 6.8ns ± 0% -79.97% FilterInstances/1↑/up-8 37.2ns ± 0% 9.4ns ± 0% -74.62% FilterInstances/10↑/all-8 124ns ± 0% 28ns ± 0% -77.18% FilterInstances/10↑/none-8 113ns ± 0% 27ns ± 0% -76.28% FilterInstances/10↑/up-8 150ns ± 0% 63ns ± 0% -58.27% FilterInstances/100↑/all-8 689ns ± 0% 263ns ± 0% -61.83% FilterInstances/100↑/none-8 618ns ± 0% 229ns ± 0% -62.94% FilterInstances/100↑/up-8 945ns ± 0% 547ns ± 0% -42.12% FilterInstances/1000↑/all-8 6.32µs ± 0% 2.55µs ± 0% -59.68% FilterInstances/1000↑/none-8 5.57µs ± 0% 2.20µs ± 0% -60.52% FilterInstances/1000↑/up-8 8.63µs ± 0% 5.38µs ± 0% -37.65% FilterInstances/1↑1↓/all-8 42.7ns ± 0% 8.5ns ± 0% -80.05% FilterInstances/1↑1↓/none-8 39.5ns ± 0% 9.1ns ± 0% -76.96% FilterInstances/1↑1↓/up-8 44.2ns ± 0% 13.0ns ± 0% -70.59% FilterInstances/1↑9↓/all-8 123ns ± 0% 29ns ± 0% -76.67% FilterInstances/1↑9↓/none-8 114ns ± 0% 27ns ± 0% -76.32% FilterInstances/1↑9↓/up-8 124ns ± 0% 39ns ± 0% -68.55% FilterInstances/1↑99↓/all-8 683ns ± 0% 257ns ± 0% -62.37% FilterInstances/1↑99↓/none-8 624ns ± 0% 232ns ± 0% -62.82% FilterInstances/1↑99↓/up-8 688ns ± 0% 355ns ± 0% -48.40% FilterInstances/1↑999↓/all-8 6.31µs ± 0% 2.50µs ± 0% -60.31% FilterInstances/1↑999↓/none-8 5.59µs ± 0% 2.31µs ± 0% -58.76% FilterInstances/1↑999↓/up-8 6.21µs ± 0% 3.32µs ± 0% -46.51% FilterInstances/9↑1↓/all-8 121ns ± 0% 29ns ± 0% -76.12% FilterInstances/9↑1↓/none-8 114ns ± 0% 26ns ± 0% -76.84% FilterInstances/9↑1↓/up-8 148ns ± 0% 57ns ± 0% -61.42% FilterInstances/99↑1↓/all-8 683ns ± 0% 258ns ± 0% -62.23% FilterInstances/99↑1↓/none-8 617ns ± 0% 233ns ± 0% -62.24% FilterInstances/99↑1↓/up-8 934ns ± 0% 539ns ± 0% -42.29% FilterInstances/999↑1↓/all-8 6.33µs ± 0% 2.55µs ± 0% -59.79% FilterInstances/999↑1↓/none-8 5.56µs ± 0% 2.20µs ± 0% -60.49% FilterInstances/999↑1↓/up-8 8.67µs ± 0% 5.46µs ± 0% -37.05% FilterInstances/3↓4↑3↓/all-8 121ns ± 0% 29ns ± 0% -76.20% FilterInstances/3↓4↑3↓/none-8 113ns ± 0% 26ns ± 0% -76.55% FilterInstances/3↓4↑3↓/up-8 137ns ± 0% 46ns ± 0% -66.57% FilterInstances/3↑4↓3↑/all-8 122ns ± 0% 29ns ± 0% -76.56% FilterInstances/3↑4↓3↑/none-8 112ns ± 0% 26ns ± 0% -76.43% FilterInstances/3↑4↓3↑/up-8 140ns ± 0% 151ns ± 0% +7.86% FilterInstances/33↓34↑33↓/all-8 679ns ± 0% 269ns ± 0% -60.38% FilterInstances/33↓34↑33↓/none-8 619ns ± 0% 232ns ± 0% -62.52% FilterInstances/33↓34↑33↓/up-8 793ns ± 0% 411ns ± 0% -48.17% FilterInstances/33↑34↓33↑/all-8 680ns ± 0% 259ns ± 0% -61.91% FilterInstances/33↑34↓33↑/none-8 626ns ± 0% 230ns ± 0% -63.26% FilterInstances/33↑34↓33↑/up-8 990ns ± 0% 761ns ± 0% -23.13% FilterInstances/333↓334↑333↓/all-8 7.05µs ± 0% 2.50µs ± 0% -64.59% FilterInstances/333↓334↑333↓/none-8 5.89µs ± 0% 2.19µs ± 0% -62.77% FilterInstances/333↓334↑333↓/up-8 7.13µs ± 0% 3.88µs ± 0% -45.55% FilterInstances/333↑334↓333↑/all-8 6.31µs ± 0% 2.53µs ± 0% -59.95% FilterInstances/333↑334↓333↑/none-8 5.56µs ± 0% 2.19µs ± 0% -60.61% FilterInstances/333↑334↓333↑/up-8 7.78µs ± 0% 6.43µs ± 0% -17.38%
Following the pattern established by EurekaConnection's ScheduleAppUpdates method, attempt to retrieve the latest set of instances for a given VIP address periodically, feeding the outcome into a supplied channel until told to stop.
Allow all example functions to be niladic as intended, but share a means of acquiring a EurekaConnection instance.
6a12f2d
to
72404f4
Compare
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.
Per the preceding discussion in #53, and sitting on top of #54, poll the instances for a VIP address periodically. This implements the "consuming" capability mentioned in #53, with a contraction in the method names down to
EurekaConnection.ScheduleVIPAddressUpdates
andEurekaConnection.ScheduleSecureVIPAddressUpdates
, not mentioning the word "instance" there.I used the same "functional options" technique first appearing in #54 for the following options that one can supply to
GetInstancesByVIPAddress
,GetInstancesBySecureVIPAddress
,ScheduleVIPAddressUpdates
, andScheduleSecureVIPAddressUpdates
:WithStatus
ThatAreUp
Shuffled
ShuffledWith
I intend to apply those options to the "caching" factory functions as well.