Repository navigation
Add hedge-trigger, final-outcome, attempted-payload and excluded-leader metrics #87
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
Changes from 12 commits
bb312b1
16669d5
ed18375
1d7d5c1
89da2f7
00dd6b5
b880d9f
6b3fd94
d109506
f4a614c
246d707
b88a842
21f50fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package wgo | |
| import ( | ||
| "context" | ||
| "fmt" | ||
| "slices" | ||
| "sort" | ||
| "sync/atomic" | ||
| "time" | ||
|
|
@@ -92,6 +93,8 @@ func (p *AgentPool) refresh(ctx context.Context) (removed []int32, dropped leade | |
| newAgents = append(newAgents, b.NodeID) | ||
| } | ||
| sort.Slice(newAgents, func(i, j int) bool { return newAgents[i] < newAgents[j] }) | ||
| // A NodeID listed twice is still one agent. | ||
| newAgents = slices.Compact(newAgents) | ||
|
|
||
| agentSet := make(map[int32]struct{}, len(newAgents)) | ||
| for _, id := range newAgents { | ||
|
|
@@ -224,3 +227,25 @@ func diffRemovedAgents(old []int32, newSet map[int32]struct{}) []int32 { | |
| } | ||
| return removed | ||
| } | ||
|
|
||
| // diffAgentMembership counts NodeIDs that appeared or disappeared between two | ||
| // sorted, unique agent lists. | ||
| func diffAgentMembership(old, new []int32) (added, removed int) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. refresh now deduplicates NodeIDs after sorting. It was worse than described: the pool itself held the duplicate and membership_changed was also counted. Added a test that duplicates a broker in the Metadata response.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm reverting this. A correct Metadata response contains one entry per NodeID, and a duplicate is treated as malformed, so the sorted list already satisfies diffAgentMembership. Compacting also changes fallback routing for a malformed response ( |
||
| i, j := 0, 0 | ||
| for i < len(old) && j < len(new) { | ||
| switch { | ||
| case old[i] == new[j]: | ||
| i++ | ||
| j++ | ||
| case old[i] < new[j]: | ||
| removed++ | ||
| i++ | ||
| default: | ||
| added++ | ||
| j++ | ||
| } | ||
| } | ||
| removed += len(old) - i | ||
| added += len(new) - j | ||
| return added, removed | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.