v3go.etcd.io/etcd/pkg/v3/schedule Index | Files

package schedule

import "go.etcd.io/etcd/pkg/v3/schedule"

Package schedule provides mechanisms and policies for scheduling units of work.

Index

Types

type Job

type Job interface {
	Name() string
	Do(context.Context)
}

func NewJob

func NewJob(name string, do func(ctx context.Context)) Job

type Scheduler

type Scheduler interface {
	// Schedule asks the scheduler to schedule a job defined by the given func.
	// Schedule to a stopped scheduler might panic.
	Schedule(j Job)

	// Pending returns number of pending jobs
	Pending() int

	// Scheduled returns the number of scheduled jobs (excluding pending jobs)
	Scheduled() int

	// Finished returns the number of finished jobs
	Finished() int

	// WaitFinish waits until at least n job are finished and all pending jobs are finished.
	WaitFinish(n int)

	// Stop stops the scheduler.
	Stop()
}

Scheduler can schedule jobs.

func NewFIFOScheduler

func NewFIFOScheduler(lg *zap.Logger) Scheduler

NewFIFOScheduler returns a Scheduler that schedules jobs in FIFO order sequentially

Source Files

doc.go schedule.go

Version
v3.6.1 (latest)
Published
Jun 6, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
1 week ago

Tools for package owners.