console

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package console is the queue's commands.

It mirrors Illuminate\Queue\Console. Each command is a struct built with the collaborators it needs and turned into a console.Command by its Command method, which is how every command in the collection is written: the registry and the compiler read the same slice, so a command missing from it does not exist and one in it with a broken Run does not build.

reg.Add(
	console.NewWorkCommand(worker, manager).Command(),
	console.NewRestartCommand(manager).Command(),
)

Every failed job command takes a tenant

A failed job carries a customer's payload, so `aru queue:failed` is a read like any other and it is scoped: --tenant is required and has no default (RULE 17). Laravel's commands have no equivalent because Laravel has no tenant, and a listing that defaulted would print whichever customer happened to sort first.

The files it answers to, in the clone at laravel_illuminate/queue/Console:

BatchesTableCommand.php    -- see below
ClearCommand.php           -> ClearCommand
FailedTableCommand.php     -- see below
FlushFailedCommand.php     -> FlushFailedCommand
ForgetFailedCommand.php    -> ForgetFailedCommand
ListFailedCommand.php      -> ListFailedCommand
ListenCommand.php          -> ListenCommand
MonitorCommand.php         -> MonitorCommand
PauseCommand.php           -> PauseCommand
PruneBatchesCommand.php    -> PruneBatchesCommand
PruneFailedJobsCommand.php -> PruneFailedJobsCommand
RestartCommand.php         -> RestartCommand
ResumeCommand.php          -> ResumeCommand
RetryBatchCommand.php      -> RetryBatchCommand
RetryCommand.php           -> RetryCommand
TableCommand.php           -- see below
WorkCommand.php            -> WorkCommand

The three table commands -- make:queue-table, make:queue-failed-table, make:queue-batches-table -- have no counterpart, and that is not an omission. In Laravel they write a migration file into the application because the schema belongs to the application; here it belongs to whoever owns the table and travels with them: queue.DatabaseQueue.Migrations is the jobs table and failed.DatabaseFailedJobProvider.Migrations is the failed jobs table, both collected by the module. A generator that copied them into the project would be a second copy that drifts (RULE 9).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClearCommand

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

ClearCommand deletes every job waiting on a queue.

It answers Illuminate\Queue\Console\ClearCommand: `queue:clear`. Parked jobs are not cleared -- a job that gave up is in the dead letter list, not on a queue, and `aru queue:flush` is what empties that.

func NewClearCommand

func NewClearCommand(m *queue.QueueManager) *ClearCommand

NewClearCommand returns the command.

func (*ClearCommand) Command

func (c *ClearCommand) Command() console.Command

Command is the registry entry for queue:clear.

func (*ClearCommand) Handle

func (c *ClearCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers ClearCommand::handle().

It asks first, unless --force. Laravel's confirmToProceed() only asks in production; this asks everywhere, because a queue with jobs on it is somebody's work whichever environment it is in.

type FlushFailedCommand

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

FlushFailedCommand deletes the failed jobs.

It answers Illuminate\Queue\Console\FlushFailedCommand: `queue:flush`, with --hours to keep the recent ones.

func NewFlushFailedCommand

func NewFlushFailedCommand(p failed.FailedJobProvider) *FlushFailedCommand

NewFlushFailedCommand returns the command.

func (*FlushFailedCommand) Command

func (c *FlushFailedCommand) Command() console.Command

Command is the registry entry for queue:flush.

func (*FlushFailedCommand) Handle

func (c *FlushFailedCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers FlushFailedCommand::handle().

type ForgetFailedCommand

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

ForgetFailedCommand deletes one failed job.

It answers Illuminate\Queue\Console\ForgetFailedCommand: `queue:forget`.

func NewForgetFailedCommand

func NewForgetFailedCommand(p failed.FailedJobProvider) *ForgetFailedCommand

NewForgetFailedCommand returns the command.

func (*ForgetFailedCommand) Command

func (c *ForgetFailedCommand) Command() console.Command

Command is the registry entry for queue:forget.

func (*ForgetFailedCommand) Handle

func (c *ForgetFailedCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers ForgetFailedCommand::handle().

type ListFailedCommand

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

ListFailedCommand prints the jobs that gave up.

It answers Illuminate\Queue\Console\ListFailedCommand: `queue:failed`.

func NewListFailedCommand

func NewListFailedCommand(p failed.FailedJobProvider) *ListFailedCommand

NewListFailedCommand returns the command.

func (*ListFailedCommand) Command

func (c *ListFailedCommand) Command() console.Command

Command is the registry entry for queue:failed.

func (*ListFailedCommand) Handle

func (c *ListFailedCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers ListFailedCommand::handle().

type ListenCommand

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

ListenCommand runs a worker in a child process and restarts it when it exits.

It answers Illuminate\Queue\Console\ListenCommand: `queue:listen`. It is for development, where the point is that a rebuilt binary is picked up without anybody restarting anything -- see queue.Listener for why it is not the way to run a queue in production.

func NewListenCommand

func NewListenCommand(l *queue.Listener, options queue.ListenerOptions) *ListenCommand

NewListenCommand returns the command.

func (*ListenCommand) Command

func (c *ListenCommand) Command() console.Command

Command is the registry entry for queue:listen.

func (*ListenCommand) Handle

func (c *ListenCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers ListenCommand::handle().

type MonitorCommand

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

MonitorCommand reports how much work is waiting, and says so loudly when it is too much.

It answers Illuminate\Queue\Console\MonitorCommand: `queue:monitor`. It is meant to run on a schedule: the table is for a person, and the QueueBusy event is for whatever pages one.

func NewMonitorCommand

func NewMonitorCommand(m *queue.QueueManager, d queue.Dispatcher) *MonitorCommand

NewMonitorCommand returns the command.

The dispatcher may be nil, and then the command prints the table and announces nothing.

func (*MonitorCommand) Command

func (c *MonitorCommand) Command() console.Command

Command is the registry entry for queue:monitor.

func (*MonitorCommand) Handle

func (c *MonitorCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers MonitorCommand::handle().

type PauseCommand

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

PauseCommand stops workers taking new jobs off a queue.

It answers Illuminate\Queue\Console\PauseCommand: `queue:pause`. It is the switch to reach for when a downstream system is failing and retrying into it is making things worse.

func NewPauseCommand

func NewPauseCommand(m *queue.QueueManager) *PauseCommand

NewPauseCommand returns the command.

func (*PauseCommand) Command

func (c *PauseCommand) Command() console.Command

Command is the registry entry for queue:pause.

func (*PauseCommand) Handle

func (c *PauseCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers PauseCommand::handle().

type PruneBatchesCommand

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

PruneBatchesCommand deletes the batch rows that are old enough not to matter.

It answers Illuminate\Queue\Console\PruneBatchesCommand: `queue:prune-batches`, with the three retentions Laravel has -- finished, unfinished and cancelled -- because they are three different decisions. A finished batch is history; an unfinished one that is a week old is a bug somebody should have seen.

func NewPruneBatchesCommand

func NewPruneBatchesCommand(b bus.PrunableBatchRepository) *PruneBatchesCommand

NewPruneBatchesCommand returns the command.

It takes the prunable repository rather than the plain one, which is the Go form of the `instanceof PrunableBatchRepository` check the PHP does at the top of handle(): a store that cannot prune cannot be wired here, instead of being wired and then refusing at three in the morning.

func (*PruneBatchesCommand) Command

func (c *PruneBatchesCommand) Command() console.Command

Command is the registry entry for queue:prune-batches.

func (*PruneBatchesCommand) Handle

func (c *PruneBatchesCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers PruneBatchesCommand::handle().

type PruneFailedJobsCommand

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

PruneFailedJobsCommand deletes the failed jobs that are old enough not to matter.

It answers Illuminate\Queue\Console\PruneFailedJobsCommand: `queue:prune-failed`. It is meant to run on a schedule, which is the difference from `queue:flush`: that one is a person deciding, this one is the retention policy.

func NewPruneFailedJobsCommand

func NewPruneFailedJobsCommand(p failed.PrunableFailedJobProvider) *PruneFailedJobsCommand

NewPruneFailedJobsCommand returns the command.

func (*PruneFailedJobsCommand) Command

func (c *PruneFailedJobsCommand) Command() console.Command

Command is the registry entry for queue:prune-failed.

func (*PruneFailedJobsCommand) Handle

Handle runs the command. It answers PruneFailedJobsCommand::handle().

type RestartCommand

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

RestartCommand asks every running worker to stop after its current job.

It answers Illuminate\Queue\Console\RestartCommand: `queue:restart`. It is how a deploy replaces the workers -- the new binary starts, the old processes notice and exit cleanly, and whatever supervises them starts the new image.

func NewRestartCommand

func NewRestartCommand(m *queue.QueueManager) *RestartCommand

NewRestartCommand returns the command.

func (*RestartCommand) Command

func (c *RestartCommand) Command() console.Command

Command is the registry entry for queue:restart.

func (*RestartCommand) Handle

func (c *RestartCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers RestartCommand::handle().

type ResumeCommand

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

ResumeCommand lets workers take jobs off a paused queue again.

It answers Illuminate\Queue\Console\ResumeCommand: `queue:resume`.

func NewResumeCommand

func NewResumeCommand(m *queue.QueueManager) *ResumeCommand

NewResumeCommand returns the command.

func (*ResumeCommand) Command

func (c *ResumeCommand) Command() console.Command

Command is the registry entry for queue:resume.

func (*ResumeCommand) Handle

func (c *ResumeCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers ResumeCommand::handle().

type RetryBatchCommand

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

RetryBatchCommand puts the failed jobs of a batch back in line.

It answers Illuminate\Queue\Console\RetryBatchCommand: `queue:retry-batch`. It is `queue:retry` narrowed to one batch, which is the shape the question usually arrives in: the nightly import half-failed, and what has to be retried is the half that belongs to it.

func NewRetryBatchCommand

NewRetryBatchCommand returns the command.

func (*RetryBatchCommand) Command

func (c *RetryBatchCommand) Command() console.Command

Command is the registry entry for queue:retry-batch.

func (*RetryBatchCommand) Handle

func (c *RetryBatchCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers RetryBatchCommand::handle().

func (*RetryBatchCommand) IsolatableID

func (c *RetryBatchCommand) IsolatableID(batchID string) string

IsolatableID is the lock this command takes, which is per batch.

It answers isolatableId(), which in PHP is what makes `--isolated` mean "one at a time per batch" rather than "one at a time". Two people retrying two different batches must not block each other; two people retrying the same one must, or the jobs are pushed twice.

type RetryCommand

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

RetryCommand puts a failed job back in line.

It answers Illuminate\Queue\Console\RetryCommand: `queue:retry`, with the ids as arguments and --queue to take every failure off one queue. Without it the only way out of a dead letter list is SQL by hand, which is how it becomes a table nobody touches.

func NewRetryCommand

NewRetryCommand returns the command.

func (*RetryCommand) Command

func (c *RetryCommand) Command() console.Command

Command is the registry entry for queue:retry.

func (*RetryCommand) Handle

func (c *RetryCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers RetryCommand::handle().

The order is the PHP's, and it matters: the job is pushed back before it is forgotten, so a push that fails leaves the failure where it was. Forgetting first and then failing to push loses the job.

type WorkCommand

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

WorkCommand drains a queue.

It answers Illuminate\Queue\Console\WorkCommand: `queue:work`, with the connection as an argument and the worker's options as flags. It is the process a deployment runs beside the web one, from the same image.

The worker it runs is the one the application built, with its handlers already registered -- there is no container to resolve a job class out of, so the registry is the thing that has to be passed in (ADR 0001).

func NewWorkCommand

func NewWorkCommand(w *queue.Worker, m *queue.QueueManager) *WorkCommand

NewWorkCommand returns the command.

The manager may be nil, and then the worker drains the queue it was built with and the connection argument is refused rather than ignored.

func (*WorkCommand) Command

func (c *WorkCommand) Command() console.Command

Command is the registry entry for queue:work.

func (*WorkCommand) Handle

func (c *WorkCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers WorkCommand::handle().

The exit status is the worker's, and it is what a supervisor reads: see queue.WorkerStopReason.

Directories

Path Synopsis
Package concerns is what more than one queue command needs.
Package concerns is what more than one queue command needs.

Jump to

Keyboard shortcuts

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