-
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
base: main
Are you sure you want to change the base?
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)
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: prashanthjos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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: |
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