queue

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: BSD-3-Clause Imports: 18 Imported by: 2

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

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

func (j *Jobs) Clear() error

func (*Jobs) Commit

func (j *Jobs) Commit() error

Commit the versionDB to the underlying database.

func (*Jobs) ExecuteAll

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

func (*Jobs) Has

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

func (*Jobs) PendingJobs

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

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

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

func (jm *JobsWithMissing) Clear() error

func (*JobsWithMissing) Commit

func (jm *JobsWithMissing) Commit() error

Commit the versionDB to the underlying database.

func (*JobsWithMissing) Has

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

func (*JobsWithMissing) MissingIDs

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

func (*JobsWithMissing) NumMissingIDs

func (jm *JobsWithMissing) NumMissingIDs() int

func (*JobsWithMissing) Push

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

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

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

type Parser

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