Change listener API to allow users to decide how to handle message - #113
Open
nikola-jokic wants to merge 3 commits into
Open
Change listener API to allow users to decide how to handle message#113nikola-jokic wants to merge 3 commits into
nikola-jokic wants to merge 3 commits into
Conversation
nikola-jokic
force-pushed
the
nikola-jokic/change-listener
branch
from
July 9, 2026 08:12
83fc2e4 to
8e20e94
Compare
nikola-jokic
marked this pull request as ready for review
July 14, 2026 12:42
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the listener’s scaling callback API to a single Scaler.Scale(ctx, *RunnerScaleSetMessage) entrypoint, removing the prior per-event handler methods and the listener-owned metrics recorder hooks. The goal is to centralize message handling decisions inside the scaler implementation.
Changes:
- Replace
Scalerinterface methods (HandleJobStarted/Completed/DesiredRunnerCount) with a singleScalemethod and update mocks/tests accordingly. - Remove the
MetricsRecorderinterface and theWithMetricsRecorderoption from the listener. - Update the Docker scaleset example scaler to implement the new
ScaleAPI.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| listener/mocks_test.go | Updates generated mocks to match the new Scaler.Scale API and removes the MetricsRecorder mock. |
| listener/listener.go | Removes metrics hooks and refactors the listener to invoke Scaler.Scale for initial statistics and polled messages. |
| listener/listener_test.go | Adjusts tests to validate the new Scale callback behavior. |
| examples/dockerscaleset/scaler.go | Implements Scale in the example scaler, delegating to existing per-event helpers. |
Files not reviewed (1)
- listener/mocks_test.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+151
to
155
| if msg != nil { | ||
| lastMessageID = msg.MessageID | ||
| if err := l.client.DeleteMessage(context.WithoutCancel(ctx), msg.MessageID); err != nil { | ||
| return fmt.Errorf("failed to delete message: %w", err) | ||
| } |
Pass sessionClient into Scaler and call AcquireJobs with the RunnerRequestIDs from JobAvailableMessages before computing desired runner count, so jobs are not left unacquired.
This file contains hidden or 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
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.
No description provided.