{"id":13624770,"url":"https://github.com/pconstr/recurrent","last_synced_at":"2026-01-10T08:33:48.172Z","repository":{"id":3108975,"uuid":"4135215","full_name":"pconstr/recurrent","owner":"pconstr","description":"A redis-backed manager of recurrent jobs, for node.js","archived":false,"fork":false,"pushed_at":"2012-07-13T12:40:58.000Z","size":229,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T18:23:14.829Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pconstr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-04-25T10:03:16.000Z","updated_at":"2022-11-10T19:48:18.000Z","dependencies_parsed_at":"2022-09-09T12:40:25.065Z","dependency_job_id":null,"html_url":"https://github.com/pconstr/recurrent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pconstr%2Frecurrent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pconstr%2Frecurrent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pconstr%2Frecurrent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pconstr%2Frecurrent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pconstr","download_url":"https://codeload.github.com/pconstr/recurrent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249182450,"owners_count":21226066,"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":"2024-08-01T21:01:46.242Z","updated_at":"2026-01-10T08:33:48.106Z","avatar_url":"https://github.com/pconstr.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"recurrent\n=========\n\n[![Build Status](https://secure.travis-ci.org/pconstr/recurrent.png)](http://travis-ci.org/pconstr/recurrent)\n\nA [redis](http://redis.io)-backed manager of recurrent jobs, for [node.js](http://nodejs.org).\n\n(immature, with minimal testing and probably nasty bugs)\n\nFeatures\n--------\n\n* multiple queues, backed up by redis\n* tasks have a permanent unique id and mutable associated data\n* failed job runs are retried until they succeed or give up, with exponential back-off\n* job retries and repetitions don't pile up\n* the worker's job implementation determines at the end of each run when (and whether) to repeat\n* as many worker processes as you want spread over multiple cores and machines - but you have to start them\n\nCaveats\n-------\n\n* single point of failure in queue manager (as well as redis itself) - you need to make sure it stays up / restarts quickly and there's exactly 1 instance\n\nInstalling\n----------\n\n`npm install recurrent`\n\nRunning the manager\n-------------------\n\nMake sure redis is running and then:\n\n\u003cpre\u003e\nvar recurrent = require('recurrent');\n\n// will manage a queue q\n\nvar m = new recurrent.Manager('q').connect();\n# pass arguments for redis.createClient() to connect()\n\n\u003c/pre\u003e\n\n`recurrent` offers a (currently very incomplete) web UI:\n\n\u003cpre\u003e\nhttp.createServer(m.webUI).listen(7654);\n\u003c/pre\u003e\n\nAnd then browse to `localhost:7654`\n\nWhen the manager is not needed anymore:\n\n\u003cpre\u003e\nm.stop()\n\u003c/pre\u003e\n\nStarting a recurrent job\n------------------------\n\n\u003cpre\u003e\nvar recurrent = require('recurrent');\n\n// starts a job which will run for the first time in about 30s\n\nvar c = new recurrent.Client('q').connect();\n# pass arguments for redis.createClient() to connect()\n\nc.add('t1', new Date().getTime() + 30000, {my: 'data'}, function(err) {\n  ...\n});\n\u003c/pre\u003e\n\nAdding again the same `taskId` will reset execution time.\n\nWhen the client is not needed any more:\n\n\u003cpre\u003e\nc.stop();\n\u003c/pre\u003e\n\nRecurrent job workers\n---------------------\n\n\u003cpre\u003e\nvar recurrent = require('recurrent');\n\nfunction doWork(task, cb) {\n  // do nothing for 600s\n  console.log('got', task.id, 'with this data: ', task.data);\n  setTimeout(function () {\n    console.error('completed', task.id);\n\n    // do again in about 5s\n    cb(null, new Date().getTime()+ 5000);\n  }, 600);\n}\n\nvar w = new recurrent.Worker('q', doWork).connect();\n# pass arguments for redis.createClient to connect()\n\n\u003c/pre\u003e\n\nWhen the job worker is not needed any more:\n\n\u003cpre\u003e\nw.stop();\n\u003c/pre\u003e\n\n\nTask failure\n------------\n\nWorkers must not throw.\n\nTo signal failure a worker calls back with error.\nIt can specify a retry time:\n\n\u003cpre\u003e\ncb('something went wrong', new Date().getTime()+ 1000); // retry in 1s\n\u003c/pre\u003e\n\nOr let `recurrent` do exponential back-off\n\n\u003cpre\u003e\ncb('something went wrong');\n\u003c/pre\u003e\n\nExponential back-off can be configured per worker:\n\n\u003cpre\u003e\nvar w = new recurrent.Worker('q', doWork, {\n  minBackOff: 500, //  start backing off at 500 ms\n  maxBackOff:5000, // max back-off of 5 s\n  backOffMultiplier:1.5 // back-off 50% longer every time\n}).connect();\n\u003c/pre\u003e\n\nWhen a task is being retried after failure `task.retries` contains how many retries have been attempted (including the current one).\nIt will `undefined` for the first execution, `1` for the first retry and so on.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpconstr%2Frecurrent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpconstr%2Frecurrent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpconstr%2Frecurrent/lists"}