|
NAMEMinion::Backend::Pg - PostgreSQL backendSYNOPSISuse Minion::Backend::Pg; my $backend = Minion::Backend::Pg->new('postgresql://postgres@/test'); DESCRIPTIONMinion::Backend::Pg is a backend for Minion based on Mojo::Pg. All necessary tables will be created automatically with a set of migrations named "minion". Note that this backend uses many bleeding edge features, so only the latest, stable version of PostgreSQL is fully supported.ATTRIBUTESMinion::Backend::Pg inherits all attributes from Minion::Backend and implements the following new ones.pgmy $pg = $backend->pg; $backend = $backend->pg(Mojo::Pg->new); Mojo::Pg object used to store all data. METHODSMinion::Backend::Pg inherits all methods from Minion::Backend and implements the following new ones.broadcastmy $bool = $backend->broadcast('some_command'); my $bool = $backend->broadcast('some_command', [@args]); my $bool = $backend->broadcast('some_command', [@args], [$id1, $id2, $id3]); Broadcast remote control command to one or more workers. dequeuemy $job_info = $backend->dequeue($worker_id, 0.5); my $job_info = $backend->dequeue($worker_id, 0.5, {queues => ['important']}); Wait a given amount of time in seconds for a job, dequeue it and transition from "inactive" to "active" state, or return "undef" if queues were empty. These options are currently available:
These fields are currently available:
enqueuemy $job_id = $backend->enqueue('foo'); my $job_id = $backend->enqueue(foo => [@args]); my $job_id = $backend->enqueue(foo => [@args] => {priority => 1}); Enqueue a new job with "inactive" state. These options are currently available:
fail_jobmy $bool = $backend->fail_job($job_id, $retries); my $bool = $backend->fail_job($job_id, $retries, 'Something went wrong!'); my $bool = $backend->fail_job( $job_id, $retries, {whatever => 'Something went wrong!'}); Transition from "active" to "failed" state with or without a result, and if there are attempts remaining, transition back to "inactive" with a delay based on "backoff" in Minion. finish_jobmy $bool = $backend->finish_job($job_id, $retries); my $bool = $backend->finish_job($job_id, $retries, 'All went well!'); my $bool = $backend->finish_job( $job_id, $retries, {whatever => 'All went well!'}); Transition from "active" to "finished" state with or without a result. historymy $history = $backend->history; Get history information for job queue. These fields are currently available:
list_jobsmy $results = $backend->list_jobs($offset, $limit); my $results = $backend->list_jobs($offset, $limit, {states => ['inactive']}); Returns the information about jobs in batches. # Get the total number of results (without limit) my $num = $backend->list_jobs(0, 100, {queues => ['important']})->{total}; # Check job state my $results = $backend->list_jobs(0, 1, {ids => [$job_id]}); my $state = $results->{jobs}[0]{state}; # Get job result my $results = $backend->list_jobs(0, 1, {ids => [$job_id]}); my $result = $results->{jobs}[0]{result}; These options are currently available:
These fields are currently available:
list_locksmy $results = $backend->list_locks($offset, $limit); my $results = $backend->list_locks($offset, $limit, {names => ['foo']}); Returns information about locks in batches. # Get the total number of results (without limit) my $num = $backend->list_locks(0, 100, {names => ['bar']})->{total}; # Check expiration time my $results = $backend->list_locks(0, 1, {names => ['foo']}); my $expires = $results->{locks}[0]{expires}; These options are currently available:
These fields are currently available:
list_workersmy $results = $backend->list_workers($offset, $limit); my $results = $backend->list_workers($offset, $limit, {ids => [23]}); Returns information about workers in batches. # Get the total number of results (without limit) my $num = $backend->list_workers(0, 100)->{total}; # Check worker host my $results = $backend->list_workers(0, 1, {ids => [$worker_id]}); my $host = $results->{workers}[0]{host}; These options are currently available:
These fields are currently available:
lockmy $bool = $backend->lock('foo', 3600); my $bool = $backend->lock('foo', 3600, {limit => 20}); Try to acquire a named lock that will expire automatically after the given amount of time in seconds. An expiration time of 0 can be used to check if a named lock already exists without creating one. These options are currently available:
newmy $backend = Minion::Backend::Pg->new('postgresql://postgres@/test'); my $backend = Minion::Backend::Pg->new(Mojo::Pg->new); Construct a new Minion::Backend::Pg object. notemy $bool = $backend->note($job_id, {mojo => 'rocks', minion => 'too'}); Change one or more metadata fields for a job. Setting a value to "undef" will remove the field. receivemy $commands = $backend->receive($worker_id); Receive remote control commands for worker. register_workermy $worker_id = $backend->register_worker; my $worker_id = $backend->register_worker($worker_id); my $worker_id = $backend->register_worker( $worker_id, {status => {queues => ['default', 'important']}}); Register worker or send heartbeat to show that this worker is still alive. These options are currently available:
remove_jobmy $bool = $backend->remove_job($job_id); Remove "failed", "finished" or "inactive" job from queue. repair$backend->repair; Repair worker registry and job queue if necessary. reset$backend->reset({all => 1}); Reset job queue. These options are currently available:
retry_jobmy $bool = $backend->retry_job($job_id, $retries); my $bool = $backend->retry_job($job_id, $retries, {delay => 10}); Transition job back to "inactive" state, already "inactive" jobs may also be retried to change options. These options are currently available:
statsmy $stats = $backend->stats; Get statistics for the job queue. These fields are currently available:
unlockmy $bool = $backend->unlock('foo'); Release a named lock. unregister_worker$backend->unregister_worker($worker_id); Unregister worker. SEE ALSOMinion, Minion::Guide, <https://minion.pm>, Mojolicious::Guides, <https://mojolicious.org>.
Visit the GSP FreeBSD Man Page Interface. |