Documentation
¶
Index ¶
- type MaxInFlight
- func (l *MaxInFlight) Handle(ctx context.Context, job model.Job) error
- func (l *MaxInFlight) OnAdd(obj any, inInitialList bool)
- func (l *MaxInFlight) OnDelete(obj any)
- func (l *MaxInFlight) OnUpdate(prev, curr any)
- func (l *MaxInFlight) RegisterInformer(ctx context.Context, factory informers.SharedInformerFactory) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MaxInFlight ¶
type MaxInFlight struct { // MaxInFlight sets the upper limit on number of jobs running concurrently // in the cluster. Must be at least 1. MaxInFlight int // contains filtered or unexported fields }
MaxInFlight is a job handler that wraps another job handler (typically the actual job scheduler) and only creates new jobs if the total number of jobs currently running is below a limit.
func New ¶
func New(logger *zap.Logger, scheduler model.JobHandler, maxInFlight int) *MaxInFlight
New creates a MaxInFlight limiter. maxInFlight must be at least 1.
func (*MaxInFlight) Handle ¶
Handle either passes the job onto the next handler immediately, or blocks until there is capacity. It returns model.ErrStaleJob if the job data becomes too stale while waiting for capacity.
func (*MaxInFlight) OnAdd ¶
func (l *MaxInFlight) OnAdd(obj any, inInitialList bool)
OnAdd is called by k8s to inform us a resource is added.
func (*MaxInFlight) OnDelete ¶
func (l *MaxInFlight) OnDelete(obj any)
OnDelete is called by k8s to inform us a resource is deleted.
func (*MaxInFlight) OnUpdate ¶
func (l *MaxInFlight) OnUpdate(prev, curr any)
OnUpdate is called by k8s to inform us a resource is updated.
func (*MaxInFlight) RegisterInformer ¶
func (l *MaxInFlight) RegisterInformer(ctx context.Context, factory informers.SharedInformerFactory) error
RegisterInformer registers the limiter to listen for Kubernetes job events, and waits for cache sync.