{"id":27197695,"url":"https://github.com/preaction/minion-backend-mysql","last_synced_at":"2025-04-09T20:29:23.750Z","repository":{"id":51132253,"uuid":"102164650","full_name":"preaction/Minion-Backend-mysql","owner":"preaction","description":"MySQL backend for the 🐙 Minion job runner","archived":false,"fork":false,"pushed_at":"2024-05-22T17:56:14.000Z","size":302,"stargazers_count":7,"open_issues_count":7,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-18T18:51:19.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preaction.png","metadata":{"files":{"readme":"README.mkdn","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-02T01:24:18.000Z","updated_at":"2024-05-22T17:56:18.000Z","dependencies_parsed_at":"2022-09-13T08:42:09.189Z","dependency_job_id":"a80f6405-333d-4bfd-9351-e886fb3c3361","html_url":"https://github.com/preaction/Minion-Backend-mysql","commit_stats":{"total_commits":190,"total_committers":14,"mean_commits":"13.571428571428571","dds":"0.24736842105263157","last_synced_commit":"af792882d757a53d1e4d2aaefbb1b208bd1231ab"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FMinion-Backend-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FMinion-Backend-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FMinion-Backend-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FMinion-Backend-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preaction","download_url":"https://codeload.github.com/preaction/Minion-Backend-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248106799,"owners_count":21048797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-09T20:29:23.027Z","updated_at":"2025-04-09T20:29:23.730Z","avatar_url":"https://github.com/preaction.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/preaction/Minion-Backend-mysql.svg?branch=master)](https://travis-ci.org/preaction/Minion-Backend-mysql)\n[![Coverage Status](https://coveralls.io/repos/preaction/Minion-Backend-mysql/badge.svg?branch=master)](https://coveralls.io/r/preaction/Minion-Backend-mysql?branch=master)\n\n# NAME\n\nMinion::Backend::mysql\n\n# VERSION\n\nversion 1.006\n\n# SYNOPSIS\n\n    use Mojolicious::Lite;\n\n    plugin Minion =\u003e {mysql =\u003e 'mysql://user@127.0.0.1/minion_jobs'};\n\n    # Slow task\n    app-\u003eminion-\u003eadd_task(poke_mojo =\u003e sub {\n      my $job = shift;\n      $job-\u003eapp-\u003eua-\u003eget('mojolicio.us');\n      $job-\u003eapp-\u003elog-\u003edebug('We have poked mojolicio.us for a visitor');\n    });\n\n    # Perform job in a background worker process\n    get '/' =\u003e sub {\n      my $c = shift;\n      $c-\u003eminion-\u003eenqueue('poke_mojo');\n      $c-\u003erender(text =\u003e 'We will poke mojolicio.us for you soon.');\n    };\n\n    app-\u003estart;\n\n# DESCRIPTION\n\n[Minion::Backend::mysql](https://metacpan.org/pod/Minion::Backend::mysql) is a backend for [Minion](https://metacpan.org/pod/Minion) based on [Mojo::mysql](https://metacpan.org/pod/Mojo::mysql). All\nnecessary tables will be created automatically with a set of migrations named\n`minion`. This backend requires at least v5.6.5 of MySQL.\n\n# NAME\n\nMinion::Backend::mysql - MySQL backend\n\n# ATTRIBUTES\n\n[Minion::Backend::mysql](https://metacpan.org/pod/Minion::Backend::mysql) inherits all attributes from [Minion::Backend](https://metacpan.org/pod/Minion::Backend) and\nimplements the following new ones.\n\n## mysql\n\n    my $mysql   = $backend-\u003emysql;\n    $backend = $backend-\u003emysql(Mojo::mysql-\u003enew);\n\n[Mojo::mysql](https://metacpan.org/pod/Mojo::mysql) object used to store all data.\n\n## no\\_txn\n\nIf true, will not make a transaction around the [\"enqueue\"](#enqueue) insertions\nwhen a job has parent jobs. Without a transaction, the job could be\ndequeued before its parent relationships are written to the database.\nHowever, since MySQL does not support nested transactions (despite\nsupporting something almost exactly like them...), you can disable\ntransactions for testing by setting this attribute (if you perform your\ntests in a transaction so they can be rolled back when the test is\ncomplete).\n\n# METHODS\n\n[Minion::Backend::mysql](https://metacpan.org/pod/Minion::Backend::mysql) inherits all methods from [Minion::Backend](https://metacpan.org/pod/Minion::Backend) and\nimplements the following new ones.\n\n## dequeue\n\n    my $job_info = $backend-\u003edequeue($worker_id, 0.5);\n    my $job_info = $backend-\u003edequeue($worker_id, 0.5, {queues =\u003e ['important']});\n\nWait for job, dequeue it and transition from `inactive` to `active` state or\nreturn `undef` if queues were empty.\n\nThese options are currently available:\n\n- queues\n\n        queues =\u003e ['important']\n\n    One or more queues to dequeue jobs from, defaults to `default`.\n\nThese fields are currently available:\n\n- args\n\n        args =\u003e ['foo', 'bar']\n\n    Job arguments.\n\n- id\n\n        id =\u003e '10023'\n\n    Job ID.\n\n- retries\n\n        retries =\u003e 3\n\n    Number of times job has been retried.\n\n- task\n\n        task =\u003e 'foo'\n\n    Task name.\n\n## enqueue\n\n    my $job_id = $backend-\u003eenqueue('foo');\n    my $job_id = $backend-\u003eenqueue(foo =\u003e [@args]);\n    my $job_id = $backend-\u003eenqueue(foo =\u003e [@args] =\u003e {priority =\u003e 1});\n\nEnqueue a new job with `inactive` state.\n\nThese options are currently available:\n\n- delay\n\n        delay =\u003e 10\n\n    Delay job for this many seconds (from now).\n\n- priority\n\n        priority =\u003e 5\n\n    Job priority, defaults to `0`.\n\n- queue\n\n        queue =\u003e 'important'\n\n    Queue to put job in, defaults to `default`.\n\n## fail\\_job\n\n    my $bool = $backend-\u003efail_job($job_id, $retries);\n    my $bool = $backend-\u003efail_job($job_id, $retries, 'Something went wrong!');\n    my $bool = $backend-\u003efail_job(\n      $job_id, $retries, {msg =\u003e 'Something went wrong!'});\n\nTransition from `active` to `failed` state.\n\n## finish\\_job\n\n    my $bool = $backend-\u003efinish_job($job_id, $retries);\n    my $bool = $backend-\u003efinish_job($job_id, $retries, 'All went well!');\n    my $bool = $backend-\u003efinish_job($job_id, $retries, {msg =\u003e 'All went well!'});\n\nTransition from `active` to `finished` state.\n\n## job\\_info\n\n    my $job_info = $backend-\u003ejob_info($job_id);\n\nGet information about a job or return `undef` if job does not exist.\n\n    # Check job state\n    my $state = $backend-\u003ejob_info($job_id)-\u003e{state};\n\n    # Get job result\n    my $result = $backend-\u003ejob_info($job_id)-\u003e{result};\n\nThese fields are currently available:\n\n- args\n\n        args =\u003e ['foo', 'bar']\n\n    Job arguments.\n\n- created\n\n        created =\u003e 784111777\n\n    Time job was created.\n\n- delayed\n\n        delayed =\u003e 784111777\n\n    Time job was delayed to.\n\n- finished\n\n        finished =\u003e 784111777\n\n    Time job was finished.\n\n- priority\n\n        priority =\u003e 3\n\n    Job priority.\n\n- queue\n\n        queue =\u003e 'important'\n\n    Queue name.\n\n- result\n\n        result =\u003e 'All went well!'\n\n    Job result.\n\n- retried\n\n        retried =\u003e 784111777\n\n    Time job has been retried.\n\n- retries\n\n        retries =\u003e 3\n\n    Number of times job has been retried.\n\n- started\n\n        started =\u003e 784111777\n\n    Time job was started.\n\n- state\n\n        state =\u003e 'inactive'\n\n    Current job state, usually `active`, `failed`, `finished` or `inactive`.\n\n- task\n\n        task =\u003e 'foo'\n\n    Task name.\n\n- worker\n\n        worker =\u003e '154'\n\n    Id of worker that is processing the job.\n\n## list\\_jobs\n\n    my $batch = $backend-\u003elist_jobs($offset, $limit);\n    my $batch = $backend-\u003elist_jobs($offset, $limit, {states =\u003e 'inactive'});\n\nReturns the same information as [\"job\\_info\"](#job_info) but in batches.\n\nThese options are currently available:\n\n- state\n\n        state =\u003e 'inactive'\n\n    List only jobs in this state.\n\n- task\n\n        task =\u003e 'test'\n\n    List only jobs for this task.\n\n## list\\_workers\n\n    my $batch = $backend-\u003elist_workers($offset, $limit);\n\nReturns the same information as [\"worker\\_info\"](#worker_info) but in batches.\n\n## new\n\n    my $backend = Minion::Backend::mysql-\u003enew('mysql://mysql@/test');\n\nConstruct a new [Minion::Backend::mysql](https://metacpan.org/pod/Minion::Backend::mysql) object.\n\n## register\\_worker\n\n    my $worker_id = $backend-\u003eregister_worker;\n    my $worker_id = $backend-\u003eregister_worker($worker_id);\n\nRegister worker or send heartbeat to show that this worker is still alive.\n\n## remove\\_job\n\n    my $bool = $backend-\u003eremove_job($job_id);\n\nRemove `failed`, `finished` or `inactive` job from queue.\n\n## repair\n\n    $backend-\u003erepair;\n\nRepair worker registry and job queue if necessary.\n\n## reset\n\n    $backend-\u003ereset;\n\nReset job queue.\n\n## retry\\_job\n\n    my $bool = $backend-\u003eretry_job($job_id, $retries);\n    my $bool = $backend-\u003eretry_job($job_id, $retries, {delay =\u003e 10});\n\nTransition from `failed` or `finished` state back to `inactive`.\n\nThese options are currently available:\n\n- delay\n\n        delay =\u003e 10\n\n    Delay job for this many seconds (from now).\n\n- parents\n\n        parents =\u003e [$id1, $id2, $id3]\n\n    Jobs this job depends on.\n\n- priority\n\n        priority =\u003e 5\n\n    Job priority.\n\n- queue\n\n        queue =\u003e 'important'\n\n    Queue to put job in.\n\n## stats\n\n    my $stats = $backend-\u003estats;\n\nGet statistics for jobs and workers.\n\n## unregister\\_worker\n\n    $backend-\u003eunregister_worker($worker_id);\n\nUnregister worker.\n\n## worker\\_info\n\n    my $worker_info = $backend-\u003eworker_info($worker_id);\n\nGet information about a worker or return `undef` if worker does not exist.\n\n    # Check worker host\n    my $host = $backend-\u003eworker_info($worker_id)-\u003e{host};\n\nThese fields are currently available:\n\n- host\n\n        host =\u003e 'localhost'\n\n    Worker host.\n\n- jobs\n\n        jobs =\u003e ['10023', '10024', '10025', '10029']\n\n    Ids of jobs the worker is currently processing.\n\n- notified\n\n        notified =\u003e 784111777\n\n    Last time worker sent a heartbeat.\n\n- pid\n\n        pid =\u003e 12345\n\n    Process id of worker.\n\n- started\n\n        started =\u003e 784111777\n\n    Time worker was started.\n\n# ERRORS\n\n## DBD::mysql::st execute failed: Table '\\*.minion\\_workers' doesn't exist\n\nThis may happen when the SQL create/upgrade scripts fail to run\ncompletely due to permission errors. Re-running with the environment\nvariable `MOJO_MIGRATIONS_DEBUG=1` should produce the error message\nreturned by the database.\n\nA common reason for the database install to fail on MySQL \u003e= 8 is that\nthe user installing the database does not have `SUPER` privileges\nneeded to create functions when binlogs are enabled: (`DBD::mysql::st\nexecute failed: You do not have the SUPER privilege and binary logging\nis enabled`). See [the MySQL documentation for Stored Program Binary\nLogging](https://dev.mysql.com/doc/refman/8.0/en/stored-programs-logging.html)\nfor more information about this problem and how to correct it.\n\n# SEE ALSO\n\n[Minion](https://metacpan.org/pod/Minion), [Mojolicious::Guides](https://metacpan.org/pod/Mojolicious::Guides), [http://mojolicio.us](http://mojolicio.us).\n\n# AUTHORS\n\n- Brian Medley \u003cbpmedley@cpan.org\u003e\n- Doug Bell \u003cpreaction@cpan.org\u003e\n\n# CONTRIBUTORS\n\n- a-leelan \u003c40534142+a-leelan@users.noreply.github.com\u003e\n- Alexander Nalobin \u003cnalobin@reg.ru\u003e\n- Dmitry Krylov \u003cpentabion@gmail.com\u003e\n- Hu Yin \u003chuyin8@gmail.com\u003e\n- Jason A. Crome \u003cjcrome@empoweredbenefits.com\u003e\n- Larry Leszczynski \u003clarryl@cpan.org\u003e\n- Larry Leszczynski \u003clarryl@emailplus.org\u003e\n- Olaf Alders \u003colaf@wundersolutions.com\u003e\n- Paul Cochrane \u003cpaul@liekut.de\u003e\n- Peter Joh \u003cpeter.joh@grantstreet.com\u003e\n- Sergey Andreev \u003c40195653+saintserge@users.noreply.github.com\u003e\n- Zoffix Znet \u003ccpan@zoffix.com\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2021 by Doug Bell and Brian Medley.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreaction%2Fminion-backend-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreaction%2Fminion-backend-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreaction%2Fminion-backend-mysql/lists"}