Skip to content

Change listener API to allow users to decide how to handle message - #113

Open
nikola-jokic wants to merge 3 commits into
mainfrom
nikola-jokic/change-listener
Open

Change listener API to allow users to decide how to handle message#113
nikola-jokic wants to merge 3 commits into
mainfrom
nikola-jokic/change-listener

Conversation

@nikola-jokic

Copy link
Copy Markdown
Contributor

No description provided.

@nikola-jokic
nikola-jokic force-pushed the nikola-jokic/change-listener branch from 83fc2e4 to 8e20e94 Compare July 9, 2026 08:12
@nikola-jokic
nikola-jokic marked this pull request as ready for review July 14, 2026 12:42
@nikola-jokic
nikola-jokic requested a review from a team as a code owner July 14, 2026 12:42
Copilot AI review requested due to automatic review settings July 14, 2026 12:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 Scaler interface methods (HandleJobStarted/Completed/DesiredRunnerCount) with a single Scale method and update mocks/tests accordingly.
  • Remove the MetricsRecorder interface and the WithMetricsRecorder option from the listener.
  • Update the Docker scaleset example scaler to implement the new Scale API.

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 thread listener/listener.go
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)
}
Comment thread examples/dockerscaleset/scaler.go
Pass sessionClient into Scaler and call AcquireJobs with the
RunnerRequestIDs from JobAvailableMessages before computing
desired runner count, so jobs are not left unacquired.
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.

3 participants