Skip to content

PB-927: introduce Baton and BatonHolder#3722

Closed
zhming0 wants to merge 1 commit intopb-927-update-agent-to-consume-the-new-connectrpc-endpointfrom
pb-927-baton
Closed

PB-927: introduce Baton and BatonHolder#3722
zhming0 wants to merge 1 commit intopb-927-update-agent-to-consume-the-new-connectrpc-endpointfrom
pb-927-baton

Conversation

@zhming0
Copy link
Contributor

@zhming0 zhming0 commented Feb 27, 2026

Description

Rework toggle -> Baton and BatonHolder.
More explicit protocol re which one hold the baton, which one is not.
Use descriptive method to encapsulate acquire and release operation.
As a result, caller no longer need to keep track of a hasToggle concept internally.

Context

part of PB-927

@zhming0 zhming0 requested a review from DrJosh9000 February 27, 2026 04:08
@zhming0 zhming0 mentioned this pull request Feb 27, 2026
4 tasks
Comment on lines +31 to +32
// for case expressions, so the caller must explicitly call Acquired after
// a successful receive:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the caller must explicitly call Acquired after
a successful receive:

This is a key problem in trying to abstract this well.

Comment on lines -39 to -50
// We begin holding the toggle. (The ping loop is prevented from running.)
haveToggle := true

relinquishToggle := func() {
if !haveToggle {
// Nothing to do
return
}
a.logger.Debug("[runDebouncer] Relinquishing the toggle")
toggle <- struct{}{}
haveToggle = false
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refactor seems to be the main win of this PR.

Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are some good ideas here, mind if I not merge this and instead implement something sort of similar but different?

@zhming0
Copy link
Contributor Author

zhming0 commented Mar 1, 2026

@DrJosh9000 no problem, it was meant to be a demo of idea.

@zhming0 zhming0 closed this Mar 1, 2026
@zhming0 zhming0 deleted the pb-927-baton branch March 1, 2026 23:54
@DrJosh9000
Copy link
Contributor

It's much appreciated!

@DrJosh9000 DrJosh9000 mentioned this pull request Mar 11, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants