-
Notifications
You must be signed in to change notification settings - Fork 339
Add OnConnect and OnDisconnect callbacks to ManagedConnection #3309
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
Conversation
This enables consumers to react to connection state changes without polling. Callbacks are invoked when: - OnConnect: connection is established (including reconnections) - OnDisconnect: connection is lost (with error reason)
|
Hi @prashanthjos. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This enables consumers to react to connection state changes without polling. Callbacks are invoked when: - OnConnect: connection is established (including reconnections) - OnDisconnect: connection is lost (with error reason)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3309 +/- ##
==========================================
+ Coverage 74.63% 74.66% +0.03%
==========================================
Files 188 188
Lines 8195 8207 +12
==========================================
+ Hits 6116 6128 +12
Misses 1840 1840
Partials 239 239 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@dprotaso can you please have a look at this PR, this is a pre-required PR for |
|
The callbacks need to be set before the connection goroutine starts to avoid a data race. When If we allowed setting callbacks after construction like: There's a race between the main goroutine writing the callback and the connection goroutine reading it. The functional options pattern ensures callbacks are applied atomically before the goroutine starts: |
dprotaso
left a comment
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.
Change looks good - just a minor question
| reconnectChan <- struct{}{} | ||
|
|
||
| // Wait a bit and verify no panic occurred | ||
| time.Sleep(100 * time.Millisecond) |
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.
Do we need this? Seems unnecessary - what would panic?
|
/ok-to-test |
|
/lgtm going to merge to unblock serving. can adjust the test in a follow up one we get some comments |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, prashanthjos The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This enables consumers to react to connection state changes without polling. Callbacks are invoked when:
Changes
OnConnectcallback field to ManagedConnection - invoked when connection is establishedOnDisconnectcallback field to ManagedConnection - invoked when connection is lost with error reason/kind enhancement
Fixes #
This change supports observability improvements in knative/serving#16318, where the activator needs to track autoscaler connection status. With callbacks, consumers can update metrics and logs in real-time without polling Status().
Release Note