Documentation
¶
Overview ¶
Package baqueue provides durable jobs, workers, scheduling and monitoring.
Index ¶
- Constants
- Variables
- func ApplyBatchOutcome(data map[string]any, p *JobPayload) bool
- func BatchNeedsReconciliation(data map[string]any) bool
- func ComputeDelay(b Backoff, attempt int) float64
- func MergeAttempt(stored, incoming *JobPayload) error
- func NewID() string
- func Now() float64
- func ShouldRetry(attempt, maxAttempts int) bool
- type Attempt
- type AutoBalancer
- type Backoff
- type Balancer
- type Batch
- func (b *Batch) AllowFailures() *Batch
- func (b *Batch) Catch(name string) *Batch
- func (b *Batch) Dispatch(ctx context.Context) (*BatchResult, error)
- func (b *Batch) Finally(name string) *Batch
- func (b *Batch) Name(name string) *Batch
- func (b *Batch) Tag(tags ...string) *Batch
- func (b *Batch) Then(name string) *Batch
- type BatchResult
- type Config
- type Driver
- type DriverConfig
- type Event
- type EventBus
- type EventHandler
- type FailureHandler
- type Handler
- type HandlerFunc
- type JobFilter
- type JobOption
- type JobPayload
- type JobRequest
- type MemoryDriver
- func (d *MemoryDriver) BulkDeleteJobs(ctx context.Context, ids []string, limit int) (int, error)
- func (d *MemoryDriver) Complete(ctx context.Context, p *JobPayload) error
- func (d *MemoryDriver) Connect(ctx context.Context) error
- func (d *MemoryDriver) CountJobs(ctx context.Context, f JobFilter) (int, error)
- func (d *MemoryDriver) Delete(ctx context.Context, id string) error
- func (d *MemoryDriver) Disconnect(context.Context) error
- func (d *MemoryDriver) Fail(ctx context.Context, p *JobPayload, msg string) error
- func (d *MemoryDriver) Flush(ctx context.Context, q string) error
- func (d *MemoryDriver) GetBatch(ctx context.Context, id string) (map[string]any, error)
- func (d *MemoryDriver) GetJob(ctx context.Context, id string) (*JobPayload, error)
- func (d *MemoryDriver) GetJobs(ctx context.Context, f JobFilter) ([]*JobPayload, error)
- func (d *MemoryDriver) GetMetrics(ctx context.Context, q string) (map[string]any, error)
- func (d *MemoryDriver) GetPendingBatches(ctx context.Context, limit int) ([]map[string]any, error)
- func (d *MemoryDriver) GetSupervisorStats(ctx context.Context, age float64) ([]map[string]any, error)
- func (d *MemoryDriver) IncrementBatchCounter(ctx context.Context, id, field string, delta int) (map[string]any, error)
- func (d *MemoryDriver) Pop(ctx context.Context, q string) (*JobPayload, error)
- func (d *MemoryDriver) PopDelayed(ctx context.Context) ([]*JobPayload, error)
- func (d *MemoryDriver) Promote(ctx context.Context, id string) (bool, error)
- func (d *MemoryDriver) Prune(ctx context.Context, o PruneOptions) (int, error)
- func (d *MemoryDriver) PruneMetrics(ctx context.Context, age float64) (int, error)
- func (d *MemoryDriver) PruneTerminalJobs(ctx context.Context, o PruneOptions) (int, error)
- func (d *MemoryDriver) Push(ctx context.Context, p *JobPayload) (string, error)
- func (d *MemoryDriver) PushMany(ctx context.Context, ps []*JobPayload) ([]string, error)
- func (d *MemoryDriver) Queues(ctx context.Context) ([]string, error)
- func (d *MemoryDriver) RecentThroughput(ctx context.Context, seconds int, q string) (map[string]int, error)
- func (d *MemoryDriver) ReconcileIndexes(ctx context.Context, _ int) (int, error)
- func (d *MemoryDriver) ReconcilePendingJobs(ctx context.Context, _ int) (int, error)
- func (d *MemoryDriver) RecordMetric(ctx context.Context, q, m string, v float64) error
- func (d *MemoryDriver) Release(ctx context.Context, p *JobPayload, delay float64) error
- func (d *MemoryDriver) ReportSupervisor(ctx context.Context, m map[string]any) error
- func (d *MemoryDriver) RequeueStuckJobs(ctx context.Context, age float64, q string) (int, error)
- func (d *MemoryDriver) Size(ctx context.Context, q string) (int, error)
- func (d *MemoryDriver) StoreBatch(ctx context.Context, id string, m map[string]any) error
- func (d *MemoryDriver) UpdateBatch(ctx context.Context, id string, m map[string]any) error
- type NullBalancer
- type PruneOptions
- type Pruner
- type Queue
- func (q *Queue) Batch(jobs []JobRequest) *Batch
- func (q *Queue) BuildPayload(name string, data map[string]any, options ...JobOption) (*JobPayload, error)
- func (q *Queue) Bulk(ctx context.Context, jobs []JobRequest) ([]string, error)
- func (q *Queue) Close(ctx context.Context) error
- func (q *Queue) Flush(ctx context.Context, queue string) error
- func (q *Queue) GetJob(ctx context.Context, id string) (*JobPayload, error)
- func (q *Queue) GetJobs(ctx context.Context, filter JobFilter) ([]*JobPayload, error)
- func (q *Queue) Later(ctx context.Context, name string, delay time.Duration, data map[string]any, ...) (string, error)
- func (q *Queue) Metrics(ctx context.Context, queue string) (map[string]any, error)
- func (q *Queue) Prune(ctx context.Context, o PruneOptions) (int, error)
- func (q *Queue) Push(ctx context.Context, name string, data map[string]any, options ...JobOption) (string, error)
- func (q *Queue) Queues(ctx context.Context) ([]string, error)
- func (q *Queue) ReconcileBatch(ctx context.Context, id string) error
- func (q *Queue) ReconcileBatches(ctx context.Context, limit int) (int, error)
- func (q *Queue) Register(name string, h Handler, options ...JobOption) error
- func (q *Queue) RegisterFunc(name string, h HandlerFunc, options ...JobOption) error
- func (q *Queue) RetryFailed(ctx context.Context, f JobFilter) (int, error)
- func (q *Queue) Size(ctx context.Context, queue string) (int, error)
- type RedisDriver
- func (d *RedisDriver) BulkDeleteJobs(ctx context.Context, ids []string, limit int) (int, error)
- func (d *RedisDriver) Complete(ctx context.Context, job *JobPayload) error
- func (d *RedisDriver) Connect(ctx context.Context) error
- func (d *RedisDriver) CountJobs(ctx context.Context, filter JobFilter) (int, error)
- func (d *RedisDriver) Delete(ctx context.Context, id string) error
- func (d *RedisDriver) Disconnect(context.Context) error
- func (d *RedisDriver) Fail(ctx context.Context, job *JobPayload, message string) error
- func (d *RedisDriver) Flush(ctx context.Context, queue string) error
- func (d *RedisDriver) GetBatch(ctx context.Context, id string) (map[string]any, error)
- func (d *RedisDriver) GetJob(ctx context.Context, id string) (*JobPayload, error)
- func (d *RedisDriver) GetJobs(ctx context.Context, filter JobFilter) ([]*JobPayload, error)
- func (d *RedisDriver) GetMetrics(ctx context.Context, queue string) (map[string]any, error)
- func (d *RedisDriver) GetPendingBatches(ctx context.Context, limit int) ([]map[string]any, error)
- func (d *RedisDriver) GetSupervisorStats(ctx context.Context, staleAfter float64) ([]map[string]any, error)
- func (d *RedisDriver) IncrementBatchCounter(ctx context.Context, id, field string, delta int) (map[string]any, error)
- func (d *RedisDriver) IsStorageFullError(err error) bool
- func (d *RedisDriver) Pop(ctx context.Context, queue string) (*JobPayload, error)
- func (d *RedisDriver) PopDelayed(ctx context.Context) ([]*JobPayload, error)
- func (d *RedisDriver) Promote(ctx context.Context, id string) (bool, error)
- func (d *RedisDriver) Prune(ctx context.Context, options PruneOptions) (int, error)
- func (d *RedisDriver) PruneMetrics(ctx context.Context, age float64) (int, error)
- func (d *RedisDriver) PruneTerminalJobs(ctx context.Context, options PruneOptions) (int, error)
- func (d *RedisDriver) Push(ctx context.Context, payload *JobPayload) (string, error)
- func (d *RedisDriver) PushMany(ctx context.Context, payloads []*JobPayload) ([]string, error)
- func (d *RedisDriver) Queues(ctx context.Context) ([]string, error)
- func (d *RedisDriver) RecentThroughput(ctx context.Context, seconds int, queue string) (map[string]int, error)
- func (d *RedisDriver) ReconcileIndexes(ctx context.Context, batch int) (int, error)
- func (d *RedisDriver) ReconcilePendingJobs(ctx context.Context, batch int) (int, error)
- func (d *RedisDriver) RecordMetric(ctx context.Context, queue, metric string, value float64) error
- func (d *RedisDriver) Release(ctx context.Context, job *JobPayload, delay float64) error
- func (d *RedisDriver) ReportSupervisor(ctx context.Context, stats map[string]any) error
- func (d *RedisDriver) RequeueStuckJobs(ctx context.Context, age float64, queue string) (int, error)
- func (d *RedisDriver) Size(ctx context.Context, queue string) (int, error)
- func (d *RedisDriver) StoreBatch(ctx context.Context, id string, data map[string]any) error
- func (d *RedisDriver) UpdateBatch(ctx context.Context, id string, patch map[string]any) error
- type SQLDriver
- func (d *SQLDriver) BulkDeleteJobs(ctx context.Context, ids []string, limit int) (int, error)
- func (d *SQLDriver) Complete(ctx context.Context, p *JobPayload) error
- func (d *SQLDriver) Connect(ctx context.Context) error
- func (d *SQLDriver) CountJobs(ctx context.Context, filter JobFilter) (int, error)
- func (d *SQLDriver) Delete(ctx context.Context, id string) error
- func (d *SQLDriver) Disconnect(ctx context.Context) error
- func (d *SQLDriver) Fail(ctx context.Context, p *JobPayload, message string) error
- func (d *SQLDriver) Flush(ctx context.Context, queue string) error
- func (d *SQLDriver) GetBatch(ctx context.Context, id string) (map[string]any, error)
- func (d *SQLDriver) GetJob(ctx context.Context, id string) (*JobPayload, error)
- func (d *SQLDriver) GetJobs(ctx context.Context, filter JobFilter) ([]*JobPayload, error)
- func (d *SQLDriver) GetMetrics(ctx context.Context, queue string) (map[string]any, error)
- func (d *SQLDriver) GetPendingBatches(ctx context.Context, limit int) ([]map[string]any, error)
- func (d *SQLDriver) GetSupervisorStats(ctx context.Context, staleAfter float64) ([]map[string]any, error)
- func (d *SQLDriver) IncrementBatchCounter(ctx context.Context, id, field string, delta int) (map[string]any, error)
- func (d *SQLDriver) Pop(ctx context.Context, queue string) (*JobPayload, error)
- func (d *SQLDriver) PopDelayed(ctx context.Context) ([]*JobPayload, error)
- func (d *SQLDriver) Promote(ctx context.Context, id string) (bool, error)
- func (d *SQLDriver) Prune(ctx context.Context, options PruneOptions) (int, error)
- func (d *SQLDriver) PruneMetrics(ctx context.Context, seconds float64) (int, error)
- func (d *SQLDriver) PruneTerminalJobs(ctx context.Context, options PruneOptions) (int, error)
- func (d *SQLDriver) Push(ctx context.Context, payload *JobPayload) (string, error)
- func (d *SQLDriver) PushMany(ctx context.Context, payloads []*JobPayload) ([]string, error)
- func (d *SQLDriver) Queues(ctx context.Context) ([]string, error)
- func (d *SQLDriver) RecentThroughput(ctx context.Context, seconds int, queue string) (map[string]int, error)
- func (d *SQLDriver) ReconcileIndexes(ctx context.Context, _ int) (int, error)
- func (d *SQLDriver) ReconcilePendingJobs(ctx context.Context, _ int) (int, error)
- func (d *SQLDriver) RecordMetric(ctx context.Context, queue, metric string, value float64) error
- func (d *SQLDriver) Release(ctx context.Context, p *JobPayload, delay float64) error
- func (d *SQLDriver) ReportSupervisor(ctx context.Context, stats map[string]any) error
- func (d *SQLDriver) RequeueStuckJobs(ctx context.Context, seconds float64, queue string) (int, error)
- func (d *SQLDriver) Size(ctx context.Context, queue string) (int, error)
- func (d *SQLDriver) StoreBatch(ctx context.Context, id string, data map[string]any) error
- func (d *SQLDriver) UpdateBatch(ctx context.Context, id string, data map[string]any) error
- type ScheduleEntry
- type Scheduler
- type SimpleBalancer
- type SuccessHandler
- type Supervisor
- type SupervisorConfig
- type Worker
- type WorkerOptions
Constants ¶
const ( Pending = "pending" Processing = "processing" Completed = "completed" Failed = "failed" Cancelled = "cancelled" )
const Version = "0.1.0"
Variables ¶
Functions ¶
func ApplyBatchOutcome ¶
func ApplyBatchOutcome(data map[string]any, p *JobPayload) bool
ApplyBatchOutcome is called by drivers inside the terminal job transaction. Manual retries do not reopen the original batch's first terminal outcome.
func ComputeDelay ¶
ComputeDelay returns seconds; exponential jitter is [0, 10%) with a 1h cap.
func MergeAttempt ¶
func MergeAttempt(stored, incoming *JobPayload) error
MergeAttempt preserves stored policy; only an owned attempt may update history.
func ShouldRetry ¶
Types ¶
type Attempt ¶
type Attempt struct {
Attempt int `json:"attempt"`
StartedAt float64 `json:"started_at"`
FinishedAt float64 `json:"finished_at"`
Duration float64 `json:"duration"`
Status string `json:"status"`
Error *string `json:"error"`
WillRetry bool `json:"will_retry"`
NextRetryAt *float64 `json:"next_retry_at"`
}
type AutoBalancer ¶
type AutoBalancer struct{ MinWorkers, MaxWorkers int }
type Backoff ¶
Backoff uses the same JSON representation as Python: a strategy or seconds array.
func (Backoff) MarshalJSON ¶
func (*Backoff) UnmarshalJSON ¶
type Balancer ¶
func CreateBalancer ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
func (*Batch) AllowFailures ¶
type BatchResult ¶
type Config ¶
type Config struct {
Prefix string `json:"prefix"`
Driver DriverConfig `json:"driver"`
Supervisors []SupervisorConfig `json:"supervisors"`
Schedules []ScheduleEntry `json:"schedules"`
DashboardHost string `json:"dashboard_host"`
DashboardPort int `json:"dashboard_port"`
MetricsTrimMinutes float64 `json:"metrics_trim_minutes"`
AutoPrune bool `json:"auto_prune"`
PruneIntervalSeconds float64 `json:"prune_interval_seconds"`
PruneCompletedSeconds float64 `json:"prune_completed_seconds"`
PruneOtherSeconds float64 `json:"prune_other_seconds"`
PruneMetricsSeconds float64 `json:"prune_metrics_seconds"`
PruneBatchSize int `json:"prune_batch_size"`
PruneCompletedHours float64 `json:"prune_completed_hours"`
PruneFailedHours float64 `json:"prune_failed_hours"`
PruneCancelledHours float64 `json:"prune_cancelled_hours"`
PruneMetricsHours float64 `json:"prune_metrics_hours"`
ReconcileOnConnect bool `json:"reconcile_on_connect"`
AutoCleanupOnDiskFull bool `json:"auto_cleanup_on_disk_full"`
}
func DefaultConfig ¶
func DefaultConfig() Config
type Driver ¶
type Driver interface {
Connect(context.Context) error
Disconnect(context.Context) error
Push(context.Context, *JobPayload) (string, error)
PushMany(context.Context, []*JobPayload) ([]string, error)
Pop(context.Context, string) (*JobPayload, error)
PopDelayed(context.Context) ([]*JobPayload, error)
Complete(context.Context, *JobPayload) error
Fail(context.Context, *JobPayload, string) error
Release(context.Context, *JobPayload, float64) error
RequeueStuckJobs(context.Context, float64, string) (int, error)
Delete(context.Context, string) error
Promote(context.Context, string) (bool, error)
GetJob(context.Context, string) (*JobPayload, error)
GetJobs(context.Context, JobFilter) ([]*JobPayload, error)
CountJobs(context.Context, JobFilter) (int, error)
Size(context.Context, string) (int, error)
Queues(context.Context) ([]string, error)
RecordMetric(context.Context, string, string, float64) error
GetMetrics(context.Context, string) (map[string]any, error)
RecentThroughput(context.Context, int, string) (map[string]int, error)
ReportSupervisor(context.Context, map[string]any) error
GetSupervisorStats(context.Context, float64) ([]map[string]any, error)
StoreBatch(context.Context, string, map[string]any) error
GetBatch(context.Context, string) (map[string]any, error)
GetPendingBatches(context.Context, int) ([]map[string]any, error)
UpdateBatch(context.Context, string, map[string]any) error
IncrementBatchCounter(context.Context, string, string, int) (map[string]any, error)
Prune(context.Context, PruneOptions) (int, error)
BulkDeleteJobs(context.Context, []string, int) (int, error)
PruneTerminalJobs(context.Context, PruneOptions) (int, error)
ReconcileIndexes(context.Context, int) (int, error)
ReconcilePendingJobs(context.Context, int) (int, error)
Flush(context.Context, string) error
PruneMetrics(context.Context, float64) (int, error)
}
Driver implementations must serialize claims and lifecycle transitions. Complete/Fail/Release reject stale processing attempts with ErrConflict. Release preserves attempts, max_attempts, backoff and history from storage, appending the caller's history for the current processing attempt only. Successful lifecycle writes refresh the supplied payload. Complete and Fail commit the first batch-member outcome in the same transaction as job state.
type DriverConfig ¶
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus is instance scoped; listeners run in registration order outside the lock.
func NewEventBus ¶
func NewEventBus() *EventBus
func (*EventBus) On ¶
func (e *EventBus) On(name string, fn EventHandler) func()
type FailureHandler ¶
type FailureHandler interface {
OnFailure(context.Context, error, *JobPayload) error
}
type HandlerFunc ¶
type JobOption ¶
type JobOption func(*JobPayload)
func WithBackoff ¶
func WithMaxAttempts ¶
func WithTimeout ¶
type JobPayload ¶
type JobPayload struct {
ID string `json:"id"`
JobClass string `json:"job_class"`
Data map[string]any `json:"data"`
Queue string `json:"queue"`
Attempts int `json:"attempts"`
MaxAttempts int `json:"max_attempts"`
Backoff Backoff `json:"backoff"`
Timeout float64 `json:"timeout"`
Tags []string `json:"tags"`
BatchID *string `json:"batch_id"`
DelayUntil *float64 `json:"delay_until"`
CreatedAt float64 `json:"created_at"`
UpdatedAt float64 `json:"updated_at"`
StartedAt *float64 `json:"started_at"`
CompletedAt *float64 `json:"completed_at"`
FailedAt *float64 `json:"failed_at"`
Status string `json:"status"`
Error *string `json:"error"`
History []Attempt `json:"history"`
}
JobPayload preserves Python's field names and Unix timestamps in seconds.
func NewPayload ¶
func NewPayload(name string, data map[string]any) *JobPayload
func (*JobPayload) Clone ¶
func (p *JobPayload) Clone() *JobPayload
func (*JobPayload) UnmarshalJSON ¶
func (p *JobPayload) UnmarshalJSON(raw []byte) error
Decode job data losslessly: JSON integers may exceed float64's exact range.
func (*JobPayload) Validate ¶
func (p *JobPayload) Validate() error
type MemoryDriver ¶
type MemoryDriver struct {
// contains filtered or unexported fields
}
MemoryDriver is safe for concurrent goroutines, but is not shared by processes.
func NewMemoryDriver ¶
func NewMemoryDriver() *MemoryDriver
func (*MemoryDriver) BulkDeleteJobs ¶
func (*MemoryDriver) Complete ¶
func (d *MemoryDriver) Complete(ctx context.Context, p *JobPayload) error
func (*MemoryDriver) Disconnect ¶
func (d *MemoryDriver) Disconnect(context.Context) error
func (*MemoryDriver) Fail ¶
func (d *MemoryDriver) Fail(ctx context.Context, p *JobPayload, msg string) error
func (*MemoryDriver) GetJob ¶
func (d *MemoryDriver) GetJob(ctx context.Context, id string) (*JobPayload, error)
func (*MemoryDriver) GetJobs ¶
func (d *MemoryDriver) GetJobs(ctx context.Context, f JobFilter) ([]*JobPayload, error)
func (*MemoryDriver) GetMetrics ¶
func (*MemoryDriver) GetPendingBatches ¶
func (*MemoryDriver) GetSupervisorStats ¶
func (*MemoryDriver) IncrementBatchCounter ¶
func (*MemoryDriver) Pop ¶
func (d *MemoryDriver) Pop(ctx context.Context, q string) (*JobPayload, error)
func (*MemoryDriver) PopDelayed ¶
func (d *MemoryDriver) PopDelayed(ctx context.Context) ([]*JobPayload, error)
func (*MemoryDriver) Prune ¶
func (d *MemoryDriver) Prune(ctx context.Context, o PruneOptions) (int, error)
func (*MemoryDriver) PruneMetrics ¶
func (*MemoryDriver) PruneTerminalJobs ¶
func (d *MemoryDriver) PruneTerminalJobs(ctx context.Context, o PruneOptions) (int, error)
func (*MemoryDriver) Push ¶
func (d *MemoryDriver) Push(ctx context.Context, p *JobPayload) (string, error)
func (*MemoryDriver) PushMany ¶
func (d *MemoryDriver) PushMany(ctx context.Context, ps []*JobPayload) ([]string, error)
func (*MemoryDriver) RecentThroughput ¶
func (*MemoryDriver) ReconcileIndexes ¶
func (*MemoryDriver) ReconcilePendingJobs ¶
func (*MemoryDriver) RecordMetric ¶
func (*MemoryDriver) Release ¶
func (d *MemoryDriver) Release(ctx context.Context, p *JobPayload, delay float64) error
func (*MemoryDriver) ReportSupervisor ¶
func (*MemoryDriver) RequeueStuckJobs ¶
func (*MemoryDriver) StoreBatch ¶
func (*MemoryDriver) UpdateBatch ¶
type NullBalancer ¶
type NullBalancer struct{}
type PruneOptions ¶
type PruneOptions struct {
Queue string
Status string
Tag string
OlderThanSeconds *float64
Limit int // 0 means no cap.
}
func (PruneOptions) Validate ¶
func (o PruneOptions) Validate() error
type Queue ¶
type Queue struct {
Driver Driver
Events *EventBus
Config Config
// contains filtered or unexported fields
}
func (*Queue) Batch ¶
func (q *Queue) Batch(jobs []JobRequest) *Batch
func (*Queue) BuildPayload ¶
func (*Queue) ReconcileBatch ¶
ReconcileBatch retries pending callback dispatch after worker/storage failures.
func (*Queue) ReconcileBatches ¶
func (*Queue) RegisterFunc ¶
func (q *Queue) RegisterFunc(name string, h HandlerFunc, options ...JobOption) error
func (*Queue) RetryFailed ¶
type RedisDriver ¶
type RedisDriver struct {
AutoCleanupOnDiskFull bool
ReconcileOnConnect bool
// contains filtered or unexported fields
}
RedisDriver uses the Python driver's hashes, lists and sorted-set indexes. Configure the exported options before Connect or concurrent use. Redis must retain queue keys (use noeviction); this driver targets standalone Redis. Concurrent external key-type/schema changes are unsupported. Type preflight detects existing corruption, but is not a lock against out-of-band tampering.
func NewRedisDriver ¶
func NewRedisDriver(url, prefix string) (*RedisDriver, error)
func (*RedisDriver) BulkDeleteJobs ¶
func (*RedisDriver) Complete ¶
func (d *RedisDriver) Complete(ctx context.Context, job *JobPayload) error
func (*RedisDriver) Disconnect ¶
func (d *RedisDriver) Disconnect(context.Context) error
func (*RedisDriver) Fail ¶
func (d *RedisDriver) Fail(ctx context.Context, job *JobPayload, message string) error
func (*RedisDriver) GetJob ¶
func (d *RedisDriver) GetJob(ctx context.Context, id string) (*JobPayload, error)
func (*RedisDriver) GetJobs ¶
func (d *RedisDriver) GetJobs(ctx context.Context, filter JobFilter) ([]*JobPayload, error)
func (*RedisDriver) GetMetrics ¶
func (*RedisDriver) GetPendingBatches ¶
func (*RedisDriver) GetSupervisorStats ¶
func (*RedisDriver) IncrementBatchCounter ¶
func (*RedisDriver) IsStorageFullError ¶
func (d *RedisDriver) IsStorageFullError(err error) bool
func (*RedisDriver) Pop ¶
func (d *RedisDriver) Pop(ctx context.Context, queue string) (*JobPayload, error)
func (*RedisDriver) PopDelayed ¶
func (d *RedisDriver) PopDelayed(ctx context.Context) ([]*JobPayload, error)
func (*RedisDriver) Prune ¶
func (d *RedisDriver) Prune(ctx context.Context, options PruneOptions) (int, error)
func (*RedisDriver) PruneMetrics ¶
func (*RedisDriver) PruneTerminalJobs ¶
func (d *RedisDriver) PruneTerminalJobs(ctx context.Context, options PruneOptions) (int, error)
func (*RedisDriver) Push ¶
func (d *RedisDriver) Push(ctx context.Context, payload *JobPayload) (string, error)
func (*RedisDriver) PushMany ¶
func (d *RedisDriver) PushMany(ctx context.Context, payloads []*JobPayload) ([]string, error)
func (*RedisDriver) RecentThroughput ¶
func (*RedisDriver) ReconcileIndexes ¶
ReconcileIndexes removes stale/wrong memberships and backfills missing ones. Its return value counts removed memberships, as in Python (not additions).
func (*RedisDriver) ReconcilePendingJobs ¶
ReconcilePendingJobs also discovers hashes missing from every index. Malformed hashes are retained for inspection, but cannot remain runnable.
func (*RedisDriver) RecordMetric ¶
func (*RedisDriver) Release ¶
func (d *RedisDriver) Release(ctx context.Context, job *JobPayload, delay float64) error
func (*RedisDriver) ReportSupervisor ¶
func (*RedisDriver) RequeueStuckJobs ¶
func (*RedisDriver) StoreBatch ¶
func (*RedisDriver) UpdateBatch ¶
type SQLDriver ¶
type SQLDriver struct {
AutoCleanupOnDiskFull bool
ReconcileOnConnect bool
// Set before Connect. Positive values override PostgreSQL's 16/4 defaults;
// SQLite always uses one open and one idle connection.
MaxOpenConns int
MaxIdleConns int
// contains filtered or unexported fields
}
SQLDriver implements durable SQLite and PostgreSQL storage. The baqueue_go_* tables are intentionally NOT schema-compatible with the Python drivers. Payloads use the shared JSON format; indexed columns are updated in the same transaction as the complete payload, including its attempt history.
func NewPostgresDriver ¶
NewPostgresDriver uses a Go-owned schema, separate from Python's tables. Configure the exported options before Connect; do not change them concurrently.
func NewSQLiteDriver ¶
NewSQLiteDriver uses a Go-owned schema, separate from Python's tables. Configure the exported options before Connect; do not change them concurrently.
func (*SQLDriver) BulkDeleteJobs ¶
func (*SQLDriver) GetMetrics ¶
func (*SQLDriver) GetPendingBatches ¶
func (*SQLDriver) GetSupervisorStats ¶
func (*SQLDriver) IncrementBatchCounter ¶
func (*SQLDriver) PopDelayed ¶
func (d *SQLDriver) PopDelayed(ctx context.Context) ([]*JobPayload, error)
func (*SQLDriver) PruneMetrics ¶
func (*SQLDriver) PruneTerminalJobs ¶
func (*SQLDriver) RecentThroughput ¶
func (*SQLDriver) ReconcileIndexes ¶
func (*SQLDriver) ReconcilePendingJobs ¶
func (*SQLDriver) RecordMetric ¶
func (*SQLDriver) ReportSupervisor ¶
func (*SQLDriver) RequeueStuckJobs ¶
func (*SQLDriver) StoreBatch ¶
type ScheduleEntry ¶
type Scheduler ¶
type Scheduler struct {
Queue *Queue
// contains filtered or unexported fields
}
func NewScheduler ¶
func NewScheduler(q *Queue, entries []ScheduleEntry) (*Scheduler, error)
func (*Scheduler) Add ¶
func (s *Scheduler) Add(e ScheduleEntry) error
type SimpleBalancer ¶
type SimpleBalancer struct{ MinWorkers, MaxWorkers int }
type SuccessHandler ¶
type SuccessHandler interface {
OnSuccess(context.Context, any, *JobPayload) error
}
type Supervisor ¶
type Supervisor struct {
Queue *Queue
Config SupervisorConfig
Balancer Balancer
Pruner *Pruner
// contains filtered or unexported fields
}
func NewSupervisor ¶
func NewSupervisor(q *Queue, c SupervisorConfig) *Supervisor
func (*Supervisor) Scale ¶
func (s *Supervisor) Scale(count int)
Scale retires surplus workers after their current job finishes.
func (*Supervisor) Stats ¶
func (s *Supervisor) Stats() map[string]any
type SupervisorConfig ¶
type SupervisorConfig struct {
Name string `json:"name"`
Queues []string `json:"queues"`
Balance string `json:"balance"`
MinWorkers int `json:"min_workers"`
MaxWorkers int `json:"max_workers"`
MaxJobsPerWorker int `json:"max_jobs_per_worker"`
MaxTime float64 `json:"max_time"`
Sleep float64 `json:"sleep"`
Timeout float64 `json:"timeout"`
MemoryLimit int `json:"memory_limit"`
RecoverStuckJobs bool `json:"recover_stuck_jobs"`
StuckProcessingSeconds float64 `json:"stuck_processing_seconds"`
StuckCheckIntervalSeconds float64 `json:"stuck_check_interval_seconds"`
}
func DefaultSupervisorConfig ¶
func DefaultSupervisorConfig() SupervisorConfig
func (*SupervisorConfig) UnmarshalJSON ¶
func (c *SupervisorConfig) UnmarshalJSON(b []byte) error
func (SupervisorConfig) Validate ¶
func (c SupervisorConfig) Validate() error
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
func NewWorker ¶
func NewWorker(q *Queue, o WorkerOptions) *Worker
func (*Worker) Run ¶
Run stops fetching on cancellation or Stop. Stop allows the active job to finish.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli embeds BaQueue commands in an application that registers its jobs.
|
Package cli embeds BaQueue commands in an application that registers its jobs. |
|
cmd
|
|
|
baqueue
command
|
|
|
stress
command
Stress exercises Redis recovery.
|
Stress exercises Redis recovery. |
|
Package dashboard exposes the BaQueue dashboard as a standard HTTP handler.
|
Package dashboard exposes the BaQueue dashboard as a standard HTTP handler. |
|
examples
|
|
|
dashboard
command
|
|
|
dispatch
command
|
|
|
worker
command
|