{"id":27078953,"url":"https://github.com/netlogix/netlogix.jobqueue.scheduled","last_synced_at":"2025-04-06T01:20:09.883Z","repository":{"id":39998606,"uuid":"491569971","full_name":"netlogix/Netlogix.JobQueue.Scheduled","owner":"netlogix","description":" Provide a PDO based scheduler for JobQueue jobs to defer and debounce execution","archived":false,"fork":false,"pushed_at":"2025-02-21T13:27:40.000Z","size":85,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T17:41:49.707Z","etag":null,"topics":["flow","scheduler"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netlogix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-05-12T15:28:59.000Z","updated_at":"2025-02-21T13:22:39.000Z","dependencies_parsed_at":"2024-09-16T09:01:29.493Z","dependency_job_id":"6843ec1f-fe8c-42dd-933b-b6c5a21e7ca3","html_url":"https://github.com/netlogix/Netlogix.JobQueue.Scheduled","commit_stats":{"total_commits":39,"total_committers":4,"mean_commits":9.75,"dds":0.5641025641025641,"last_synced_commit":"3f447c3f098d10b2fff3039478742385f60e064b"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlogix%2FNetlogix.JobQueue.Scheduled","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlogix%2FNetlogix.JobQueue.Scheduled/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlogix%2FNetlogix.JobQueue.Scheduled/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netlogix%2FNetlogix.JobQueue.Scheduled/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netlogix","download_url":"https://codeload.github.com/netlogix/Netlogix.JobQueue.Scheduled/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247421068,"owners_count":20936221,"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":["flow","scheduler"],"created_at":"2025-04-06T01:20:09.388Z","updated_at":"2025-04-06T01:20:09.873Z","avatar_url":"https://github.com/netlogix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Netlogix.JobQueue.Scheduled\n\nThis package provides a PDO based scheduler for JobQueue jobs.\n\nThere are two main goals:\n\n1. Schedule a Flowpack JobQueue job for later execution.\n2. Have a single job only scheduled once.\n\n\n## Installation\n```bash\ncomposer require netlogix/jobqueue-scheduled\n```\n\n## Schedule jobs\n\nThe first goal of this package is to have a way to put any kind of JobQueue job  on hold\nand mark it for later execution.\nIn contrast to e.g. \"Defer\" annotated methods or default behavior of JobQueue jobs, there\nis a time aspect to it.\nScheduled jobs are not executed immediately but at a time specified while scheduling.\n\nRegular job queue jobs need to be serializable. That's just an implementation detail of\nhow Flowpack FakeQueue and t3n RabbitQueue work.\n\nTo schedule an existing Flowpack job, just wrap it in a Scheduled Job and pass it to\nthe scheduler.\n\n```php\nuse Netlogix\\JobQueue\\Scheduled\\Domain\\Model\\ScheduledJob;\nuse Netlogix\\JobQueue\\Scheduled\\Domain\\Scheduler;\nuse Flowpack\\JobQueue\\Common\\Job\\JobInterface;\n\nassert($scheduler instanceof Scheduler);\nassert($jobqueueJob instanceof JobInterface);\n\n$dueDate = new \\DateTimeImmutable('now + 1 minute');\n$queueName = 'default';\n\n$schedulerJob = new ScheduledJob(\n    $jobqueueJob,\n    $queueName,\n    $dueDate\n);\n$scheduler-\u003eschedule($schedulerJob);\n```\n\n\n## Jobs with unique identifiers\n\nThe second goal of this package is to avoid duplicate schedules.\n\nCertain jobs don't calculate a specific computation but just \"run to the end\".\nAn example of those are the catchup jobs of the Neos.EventSourcing package.\nQueuing triggers the catchup call of\nsome event listeners.\n\nQueuing another catchup job while the first one is running is good because there might\nbe additonal changes.\n\nQueueing another catchup job while the previous one has is not even started is\nunnecessary because the first one will already catch up to the end.\n\n```php\nuse Netlogix\\JobQueue\\Scheduled\\Domain\\Model\\ScheduledJob;\nuse Netlogix\\JobQueue\\Scheduled\\Domain\\Scheduler;\nuse Flowpack\\JobQueue\\Common\\Job\\JobInterface;\n\nassert($scheduler instanceof Scheduler);\nassert($jobqueueJob instanceof JobInterface);\n\n$dueDate = new \\DateTimeImmutable('now + 1 minute');\n$queueName = 'default';\n\n$jobIdentifier = 'event-sourcing-catchup-' . $eventListenerName;\n\n$schedulerJob = new ScheduledJob(\n    $jobqueueJob,\n    $queueName,\n    $dueDate,\n    $jobIdentifier\n);\n$scheduler-\u003eschedule($schedulerJob);\n```\n\nThe \"schedule\" will only schedule a new job if the specified identifier is not already\nscheduled.\nIf there are conflicts between the existing due date and the one provided by the new\njob the earliest value is taken.\n\n\n## Queue scheduled jobs\n\nA scheduled job lives in the database and is not processed any further until queueing\nhappens.\n\nThis is currently done via cronjobs.\n\n```crontab\n* * * * *   ./flow scheduler:queueduejobs\n```\n\nThe internal scheduling mechanism will make sure only those jobs are passed from the\nscheduler to the job queue which are \"due\" according to their individual due date\nvalues.\n\n\n## Automatically schedule jobs\n\nSome jobs originate from foreign applications. An example would be one flow app\nputting a job into a RabbitMQ and another flow app consuming it.\n\nPreviously the only implementation would be a regular jobqueue worker, which neither\nprovides a way to delay execution nor a deduplication feature.\n\nNow every job can simply implement the `ScheduledJobInterface`. When `execute()`\nis triggered, it's now moved over to a scheduled jobs queue.\n\nThe job itself must provide all necessary details about how to schedule its execution.\n\n```php\nabstract class AutoScheduledJob implements ScheduledJobInterface, JobInterface {\n    public function getSchedulingInformation(): ?SchedulingInformation\n    {\n        return SchedulingInformation(\n            '97528fab-c199-4f87-b1a5-4074f1e98749',\n            'default-group',\n            new DateTimeImmutable('now')\n        );\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlogix%2Fnetlogix.jobqueue.scheduled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetlogix%2Fnetlogix.jobqueue.scheduled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetlogix%2Fnetlogix.jobqueue.scheduled/lists"}