boltjobs

package
v4.9.5 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PushBucket    string = "push"
	InQueueBucket string = "processing"
	DelayBucket   string = "delayed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configurer

type Configurer interface {
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error
	// Has checks if config section exists.
	Has(name string) bool
}

type Driver added in v4.1.0

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

func FromConfig added in v4.1.0

func FromConfig(tracer *sdktrace.TracerProvider, configKey string, log *zap.Logger, cfg Configurer, pipe jobs.Pipeline, pq jobs.Queue) (*Driver, error)

func FromPipeline

func FromPipeline(tracer *sdktrace.TracerProvider, pipeline jobs.Pipeline, log *zap.Logger, cfg Configurer, pq jobs.Queue) (*Driver, error)

func (*Driver) Pause added in v4.1.0

func (d *Driver) Pause(ctx context.Context, p string) error

func (*Driver) Push added in v4.1.0

func (d *Driver) Push(ctx context.Context, job jobs.Message) error

func (*Driver) Resume added in v4.1.0

func (d *Driver) Resume(ctx context.Context, p string) error

func (*Driver) Run added in v4.1.0

func (d *Driver) Run(ctx context.Context, p jobs.Pipeline) error

func (*Driver) State added in v4.1.0

func (d *Driver) State(ctx context.Context) (*jobs.State, error)

func (*Driver) Stop added in v4.1.0

func (d *Driver) Stop(ctx context.Context) error

type Item

type Item struct {
	// Job contains pluginName of job broker (usually PHP class).
	Job string `json:"job"`
	// Ident is unique identifier of the job, should be provided from outside
	Ident string `json:"id"`
	// Payload is string data (usually JSON) passed to Job broker.
	Payload []byte `json:"payload"`

	// Options contains set of PipelineOptions specific to job execution. Can be empty.
	Options *Options `json:"options,omitempty"`
	// contains filtered or unexported fields
}

func (*Item) Ack

func (i *Item) Ack() error

func (*Item) Body

func (i *Item) Body() []byte

func (*Item) Context

func (i *Item) Context() ([]byte, error)

func (*Item) GroupID added in v4.4.0

func (i *Item) GroupID() string

func (*Item) Headers

func (i *Item) Headers() map[string][]string

func (*Item) ID

func (i *Item) ID() string

func (*Item) Nack

func (i *Item) Nack() error

func (*Item) Priority

func (i *Item) Priority() int64

func (*Item) Requeue

func (i *Item) Requeue(headers map[string][]string, delay int64) error

Requeue algorithm:

  1. Rewrite item headers and delay.
  2. Begin writable transaction on attached to the item db.
  3. Delete item from the InQueueBucket
  4. Handle items with the delay: 4.1. Get DelayBucket 4.2. Make a key by adding the delay to the time.Now() in RFC3339 format 4.3. Put this key with value to the DelayBucket
  5. W/o delay, put the key with value to the PushBucket (requeue)

func (*Item) Respond

func (i *Item) Respond(_ []byte, _ string) error

type Options

type Options struct {
	// Priority is job priority, default - 10
	// pointer to distinguish 0 as a priority and nil as priority not set
	Priority int64 `json:"priority"`
	// Pipeline manually specified pipeline.
	Pipeline string `json:"pipeline,omitempty"`
	// Delay defines time duration to delay execution for. Defaults to none.
	Delay int64 `json:"delay,omitempty"`
	// AutoAck option
	AutoAck bool `json:"auto_ack"`
	// Push bucket
	Queue string `json:"queue,omitempty"`
	// contains filtered or unexported fields
}

Options carry information about how to handle given job.

Jump to

Keyboard shortcuts

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