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

memoryjobs

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Priority int64 `mapstructure:"priority"`
	Prefetch int64 `mapstructure:"prefetch"`
}

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 a config section exists.
	Has(name string) bool
}

type Driver

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

func FromConfig

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

func FromPipeline

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

func (*Driver) Pause

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

func (*Driver) Push

func (c *Driver) Push(ctx context.Context, jb jobs.Message) error

func (*Driver) Resume

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

func (*Driver) Run

func (c *Driver) Run(ctx context.Context, pipe jobs.Pipeline) error

func (*Driver) State

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

func (*Driver) Stop

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

type Item

type Item struct {
	// Job contains the name of job broker (usually PHP class).
	Job string `json:"job"`
	// Ident is a 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 contain a set of PipelineOptions specific to job execution. Can be empty.
	Options *Options `json:"options,omitzero"`
	// contains filtered or unexported fields
}

func (*Item) Ack

func (i *Item) Ack() error

func (*Item) Body

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

Body packs job payload into binary payload.

func (*Item) Context

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

Context packs job context (job, id) into binary payload.

func (*Item) GroupID

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) NackWithOptions

func (i *Item) NackWithOptions(redeliver bool, delay int) error

func (*Item) Priority

func (i *Item) Priority() int64

func (*Item) Requeue

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

func (*Item) Respond

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

Respond for the in-memory is no-op

type Options

type Options struct {
	// Priority is job priority, default - 10
	// pointer to distinguish 0 as a priority and nil as a priority not set
	Priority int64 `json:"priority"`

	// Pipeline manually specified pipeline.
	Pipeline string `json:"pipeline,omitzero"`

	// Delay defines time duration to delay execution for. Defaults to none.
	Delay int `json:"delay,omitzero"`
	// contains filtered or unexported fields
}

Options carry information about how to handle a given job.

func (*Options) DelayDuration

func (o *Options) DelayDuration() time.Duration

DelayDuration returns delay duration in the form of time.Duration.

Jump to

Keyboard shortcuts

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