{"id":13805418,"url":"https://github.com/msavin/stevejobs","last_synced_at":"2025-04-09T10:07:50.634Z","repository":{"id":16115672,"uuid":"70101827","full_name":"msavin/SteveJobs","owner":"msavin","description":"A simple jobs queue that just works (for Meteor.js)","archived":false,"fork":false,"pushed_at":"2024-02-16T08:20:48.000Z","size":789,"stargazers_count":206,"open_issues_count":9,"forks_count":33,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-05-19T05:33:24.949Z","etag":null,"topics":["jobs","meteor","mongodb","queue","schedule","scheduled-tasks"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/msavin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-10-05T21:44:04.000Z","updated_at":"2024-08-04T01:04:55.164Z","dependencies_parsed_at":"2024-08-04T01:15:00.435Z","dependency_job_id":null,"html_url":"https://github.com/msavin/SteveJobs","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/msavin%2FSteveJobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msavin%2FSteveJobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msavin%2FSteveJobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msavin%2FSteveJobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msavin","download_url":"https://codeload.github.com/msavin/SteveJobs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018060,"owners_count":21034048,"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":["jobs","meteor","mongodb","queue","schedule","scheduled-tasks"],"created_at":"2024-08-04T01:01:00.962Z","updated_at":"2025-04-09T10:07:50.612Z","avatar_url":"https://github.com/msavin.png","language":"JavaScript","funding_links":[],"categories":["Cron Jobs"],"sub_categories":[],"readme":"\u003cimg align=\"right\" width=\"220\" src=\"https://github.com/msavin/stevejobs/blob/master/ICON.png?raw=true\" /\u003e\n\n# Steve Jobs\n\n### The Simple Jobs Queue That Just Works\n\nRun scheduled tasks with Steve Jobs, the simple jobs queue made just for Meteor. With tight MongoDB integration and fiber-independent async timing functions, this package is quick, reliable, and effortless to use.\n\n- Jobs run on one server at a time\n- Jobs run predictably and consecutively\n- Jobs, their history, and returned data are stored in MongoDB\n- Failed jobs are retried on server restart\n- No third-party dependencies\n- Fully async/await compatible for Meteor 3.0\n\n**The new 5.0 introduces async/await support to work seamlessly with Meteor 3.0+.!** It can run hundreds of jobs in seconds with minimal CPU impact, making it a reasonable choice for many applications. To get started, check out the \u003ca href=\"https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md\"\u003e**documentation**\u003c/a\u003e and the \u003ca href=\"#quick-start\"\u003e**quick start**\u003c/a\u003e below.\n\nHuge thanks to [haryadel](https://github.com/harryadel) and [StorytellerCZ](https://github.com/StorytellerCZ) for the migration to Meteor 3.0!\n\n## Developer Friendly GUI and API\n\n\u003cimg src=\"https://github.com/msavin/SteveJobs...meteor.schedule.background.tasks.jobs.queue/blob/master/GUI.png?raw=true\"\u003e\n\nIn addition to a simple API, the Steve Jobs package offers an in-app development tool. After installing the main package, run the package command below and press Control + J in your app to open it.\n\n```\nmeteor add msavin:sjobs-ui-blaze\n```\n\nNote: this package may be a little bit flakey, and might not work if `audit-argument-checks` is present. Unfortunately, I had lost the source code, and will probably rebuild the package once there is a good reason to do so.\n\n## Quick Start\n\nFirst, install the package, and import if necessary:\n\n```bash\nmeteor add msavin:sjobs\n```\n\n```javascript\nimport { Jobs } from 'meteor/msavin:sjobs'\n```\n\nThen, write your background jobs like you would write your methods: \n\n```javascript\nawait Jobs.register({\n    \"sendReminder\": async function (to, message) {\n        const instance = this;\n\n        try {\n            const call = await HTTP.callAsync('PUT', \"http://www.magic.com/email/send\", {\n                data: {\n                    to: to,\n                    message: message,\n                    subject: \"You've Got Mail!\"\n                }\n            });\n\n            // Check if response is not 200\n            if (call.statusCode !== 200) {\n                await instance.reschedule({\n                    in: {\n                        minutes: 5\n                    }\n                });\n            } else {\n                // Return response data if successful\n                return call.data;\n            }\n\n        } catch (e) {\n            // Handle error (e.g., network issue)\n            await instance.reschedule({\n                in: {\n                    minutes: 5\n                }\n            });\n            console.error(\"Failed to send email. Rescheduling job:\", e);\n        }\n    }\n});\n```\n\nFinally, schedule a background job like you would call a method: \n\n```javascript\nawait Jobs.run(\"sendReminder\", \"jony@apple.com\", \"The future is here!\");\n```\n\nOne more thing: the function above will schedule the job to run on the moment that the function was called, however, you can delay it by passing in a special \u003ca href=\"https://github.com/msavin/SteveJobs-meteor-jobs-queue/wiki#configuration-options\"\u003e**configuration object**\u003c/a\u003e at the end:\n\n```javascript\nawait Jobs.run(\"sendReminder\", \"jony@apple.com\", \"The future is here!\", {\n    in: {\n        days: 3,\n    },\n    on: {\n        hour: 9,\n        minute: 42\n    },\n    priority: 9999999999\n});\n```\n\nThe configuration object supports `date`, `in`, `on`, `priority`, `singular`, `unique`, and `data`, all of which are completely optional. For more information, see the `Jobs.run` \u003ca href=\"https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsrun\"\u003edocumentation\u003c/a\u003e.\n\n## Repeating Jobs\n\nCompared to a CRON Job, the Steve Jobs package gives you much more control over how and when the job runs. To get started, you just need to create a job that replicates itself.\n\n```javascript\nawait Jobs.register({\n    \"syncData\": async function () {\n        const instance = this;\n        const call = await HTTP.putAsync(\"http://www.magic.com/syncData\");\n\n        if (call.statusCode === 200) {\n            await instance.replicate({\n                in: {\n                    hours: 1\n                }\n            });\n\n            // to save storage, you can remove the document\n            await instance.remove();\n        } else {\n            await instance.reschedule({\n                in: {\n                    minutes: 5\n                }\n            });\n        }\n    }\n});\n```\n\nThen, you need to \"kickstart\" the queue by creating the first job to run. By using the singular flag, you can ensure that Meteor will only create the job if there is no pending or failed instance of it.\n\n```javascript\nMeteor.startup(async function () {\n    await Jobs.run(\"syncData\", {\n        singular: true\n    })    \n})\n```\n\n## Documentation\n\n`Jobs.register` and `Jobs.run` are all you need to get started, but that's only the beginning of what the package can do. To explore the rest of the functionality, jump into the documentation:\n- [Jobs.configure](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsconfigure)\n- [Jobs.register](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsregister)\n- [Jobs.run](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsrun)\n- [Jobs.execute](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsexecute)\n- [Jobs.reschedule](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsreschedule)\n- [Jobs.replicate](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsreplicate)\n- [Jobs.start](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsstart)\n- [Jobs.stop](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsstop)\n- [Jobs.get](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsget)\n- [Jobs.cancel](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobscancel)\n- [Jobs.clear](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsclear)\n- [Jobs.remove](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobsremove)\n- [Jobs.collection](https://github.com/msavin/SteveJobs..meteor.jobs.scheduler.queue.background.tasks/blob/master/DOCUMENTATION.md#jobscollection)\n\n------\n\nSteve Jobs is an MIT-licensed project, brought to you by [**Meteor Candy**](https://www.meteorcandy.com/?ref=sjgh).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsavin%2Fstevejobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsavin%2Fstevejobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsavin%2Fstevejobs/lists"}