queue

package
v3.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFull    = errors.New("queue is full")
	ErrStopped = errors.New("queue is stopped")
)

Functions

func RegisterQueuePreload

func RegisterQueuePreload(v *vm.VM)

Types

type Channel

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

func NewChannel

func NewChannel(capacity int) *Channel

func (*Channel) Cap

func (c *Channel) Cap() int

func (*Channel) Close

func (c *Channel) Close()

func (*Channel) IsClosed

func (c *Channel) IsClosed() bool

func (*Channel) Len

func (c *Channel) Len() int

func (*Channel) Receive

func (c *Channel) Receive(timeout time.Duration) (vm.Value, Result)

func (*Channel) Send

func (c *Channel) Send(v vm.Value, timeout time.Duration) Result

type Dispatcher

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

func NewDispatcher

func NewDispatcher(capacity int) *Dispatcher

func (*Dispatcher) Clear

func (d *Dispatcher) Clear() int

func (*Dispatcher) Complete

func (d *Dispatcher) Complete(j *Job, failed bool, wait, exec time.Duration) Outcome

func (*Dispatcher) Len

func (d *Dispatcher) Len() int

func (*Dispatcher) MarkExpired

func (d *Dispatcher) MarkExpired()

func (*Dispatcher) NextDue

func (d *Dispatcher) NextDue(now time.Time) (j *Job, wait time.Duration, ok bool)

func (*Dispatcher) Snapshot

func (d *Dispatcher) Snapshot() Metrics

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

func (*Dispatcher) Stopped

func (d *Dispatcher) Stopped() bool

func (*Dispatcher) Submit

func (d *Dispatcher) Submit(j *Job) error

func (*Dispatcher) Wake

func (d *Dispatcher) Wake() <-chan struct{}

type Job

type Job struct {
	ID       string
	Priority int64
	Fn       vm.Value
	Args     []vm.Value
	Payload  vm.Value

	Enqueued time.Time
	ReadyAt  time.Time
	Timeout  time.Duration
	Attempts int
	Retries  int
	Backoff  time.Duration
	// contains filtered or unexported fields
}

func (*Job) Expired

func (j *Job) Expired(now time.Time) bool

type Metrics

type Metrics struct {
	Enqueued  int64
	Processed int64
	Succeeded int64
	Failed    int64
	Retried   int64
	Expired   int64
	Dropped   int64

	TotalWait time.Duration
	TotalExec time.Duration
	MaxWait   time.Duration
	MaxExec   time.Duration
}

func (Metrics) AvgExec

func (m Metrics) AvgExec() time.Duration

func (Metrics) AvgWait

func (m Metrics) AvgWait() time.Duration

type Outcome

type Outcome int
const (
	Succeeded Outcome = iota
	Failed
	Retried
)

type Result

type Result int
const (
	OK Result = iota
	Closed
	Timeout
)

func (Result) String

func (r Result) String() string

Jump to

Keyboard shortcuts

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