Documentation
¶
Overview ¶
Package listener provides a listener for GitHub Actions runner scale set messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
GetMessage(ctx context.Context, lastMessageID, maxCapacity int) (*scaleset.RunnerScaleSetMessage, error)
DeleteMessage(ctx context.Context, messageID int) error
Session() scaleset.RunnerScaleSetSession
}
Client defines the interface for communicating with the scaleset API. In most cases, it should be scaleset.Client from the scaleset package. This interface is defined to allow for easier testing and mocking, as well as allowing wrappers around the scaleset client if needed.
type Config ¶
type Config struct {
// ScaleSetID is the ID of the runner scale set to listen to.
ScaleSetID int
// MaxRunners is the capacity of runners that can be handled at once.
MaxRunners int
// Logger is the logger to use for logging. Default is a no-op logger.
Logger *slog.Logger
}
Config holds the configuration for the Listener.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener listens for messages from the scaleset service and handles them. It automatically handles session creation/deletion/refreshing and message polling and acking.
func (*Listener) SetMaxRunners ¶
SetMaxRunners sets the capacity of the scaleset. It is concurrently safe to update the max runners during listener.Run.
type MetricsRecorder ¶ added in v0.2.0
type MetricsRecorder interface {
RecordStatistics(statistics *scaleset.RunnerScaleSetStatistic)
RecordJobStarted(msg *scaleset.JobStarted)
RecordJobCompleted(msg *scaleset.JobCompleted)
RecordDesiredRunners(count int)
}
MetricsRecorder defines the hook methods that will be called by the listener at various points in the message handling process. This allows for custom metrics to be collected without coupling the listener to a specific metrics implementation. The methods in this interface will be called with relevant information about the message handling process, such as the number of jobs started/completed, the desired runner count, and any errors that occur. Implementers can use this information to track the performance and behavior of the listener and the scaleset service.
type Option ¶
type Option func(*Listener)
func WithMetricsRecorder ¶ added in v0.2.0
func WithMetricsRecorder(recorder MetricsRecorder) Option
WithMetricsRecorder sets the MetricsRecorder for the listener. If not set, a no-op recorder will be used. If the nil is passed, the MetricsRecorder will not be updated and the existing one will be used (which is a no-op by default).
type Scaler ¶
type Scaler interface {
HandleJobStarted(ctx context.Context, jobInfo *scaleset.JobStarted) error
HandleJobCompleted(ctx context.Context, jobInfo *scaleset.JobCompleted) error
HandleDesiredRunnerCount(ctx context.Context, count int) (int, error)
}
Scaler defines the interface for handling scale set messages.