Help us shape the future of Go! Take the 2026 Go Developer Survey

queue

package
v1.13.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2025 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	ID() ids.ID
	MissingDependencies(context.Context) (set.Set[ids.ID], error)
	// Returns true if this job has at least 1 missing dependency
	HasMissingDependencies(context.Context) (bool, error)
	Execute(context.Context) error
	Bytes() []byte
}

Job defines the interface required to be placed on the job queue.

type Jobs

type Jobs struct {
	// contains filtered or unexported fields
}

Jobs tracks a series of jobs that form a DAG of dependencies.

func New added in v0.15.6

func New(
	db database.Database,
	metricsNamespace string,
	metricsRegisterer prometheus.Registerer,
) (*Jobs, error)

New attempts to create a new job queue from the provided database.

func (*Jobs) Clear added in v0.15.6

func (j *Jobs) Clear() error

func (*Jobs) Commit added in v0.15.6

func (j *Jobs) Commit() error

Commit the versionDB to the underlying database.

func (*Jobs) ExecuteAll added in v0.15.6

func (j *Jobs) ExecuteAll(
	ctx context.Context,
	chainCtx *consensus.Context,
	halter engine.Haltable,
	restarted bool,
	acceptors ...consensus.Acceptor,
) (int, error)

func (*Jobs) Has added in v0.15.6

func (j *Jobs) Has(jobID ids.ID) (bool, error)

func (*Jobs) PendingJobs added in v0.15.6

func (j *Jobs) PendingJobs() uint64

Returns how many pending jobs are waiting in the queue.

func (*Jobs) Push

func (j *Jobs) Push(ctx context.Context, job Job) (bool, error)

Push adds a new job to the queue. Returns true if [job] was added to the queue and false if [job] was already in the queue.

func (*Jobs) SetParser added in v0.15.6

func (j *Jobs) SetParser(parser Parser) error

SetParser tells this job queue how to parse jobs from the database.

type JobsWithMissing

type JobsWithMissing struct {
	*Jobs
	// contains filtered or unexported fields
}

func NewWithMissing added in v0.15.6

func NewWithMissing(
	db database.Database,
	metricsNamespace string,
	metricsRegisterer prometheus.Registerer,
) (*JobsWithMissing, error)

func (*JobsWithMissing) AddMissingID

func (jm *JobsWithMissing) AddMissingID(jobIDs ...ids.ID)

AddMissingID adds [jobID] to missingIDs

func (*JobsWithMissing) Clear added in v0.15.6

func (jm *JobsWithMissing) Clear() error

func (*JobsWithMissing) Commit added in v0.15.6

func (jm *JobsWithMissing) Commit() error

Commit the versionDB to the underlying database.

func (*JobsWithMissing) Has added in v0.15.6

func (jm *JobsWithMissing) Has(jobID ids.ID) (bool, error)

func (*JobsWithMissing) MissingIDs

func (jm *JobsWithMissing) MissingIDs() []ids.ID

func (*JobsWithMissing) NumMissingIDs added in v0.15.6

func (jm *JobsWithMissing) NumMissingIDs() int

func (*JobsWithMissing) Push added in v0.15.6

func (jm *JobsWithMissing) Push(ctx context.Context, job Job) (bool, error)

Push adds a new job to the queue. Returns true if [job] was added to the queue and false if [job] was already in the queue.

func (*JobsWithMissing) RemoveMissingID

func (jm *JobsWithMissing) RemoveMissingID(jobIDs ...ids.ID)

RemoveMissingID removes [jobID] from missingIDs

func (*JobsWithMissing) SetParser added in v0.15.6

func (jm *JobsWithMissing) SetParser(ctx context.Context, parser Parser) error

SetParser tells this job queue how to parse jobs from the database.

type Parser added in v0.15.6

type Parser interface {
	Parse(context.Context, []byte) (Job, error)
}

Parser allows parsing a job from bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL