PHPackages                             netlogix/jobqueue-polling - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. netlogix/jobqueue-polling

ActiveNeos-package[Queues &amp; Workers](/categories/queues)

netlogix/jobqueue-polling
=========================

Shared poll scheduler for ReactPHP based job workers

00PHP

Since Jun 18Pushed todayCompare

[ Source](https://github.com/netlogix/Netlogix.JobQueue.Polling)[ Packagist](https://packagist.org/packages/netlogix/jobqueue-polling)[ RSS](/packages/netlogix-jobqueue-polling/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Netlogix.JobQueue.Polling
=========================

[](#netlogixjobqueuepolling)

This package provides a small, dependency-free poll scheduler for ReactPHP based job workers.

There are two main goals:

1. Poll for new work on a baseline interval without burning CPU when idle.
2. Pick up freed capacity immediately after a job finishes, without waiting for the next interval — while never starting more work in parallel than allowed.

It is the shared polling core used by both `Netlogix.JobQueue.FastRabbit` (one job at a time per worker) and `Netlogix.JobQueue.Scheduled` (N jobs in parallel).

Installation
------------

[](#installation)

```
composer require netlogix/jobqueue-polling
```

The problem it solves
---------------------

[](#the-problem-it-solves)

A naive worker either polls aggressively (high CPU even when there is nothing to do) or only on a slow interval (low throughput, because a freed slot waits up to one interval before the next job is picked up).

`PollScheduler` combines a periodic baseline poll with an on-demand "immediate" poll that callers trigger when a job completes. Immediate polls are coalesced to a single pending future tick, and every poll is gated by a capacity check, so a burst of completions racing the periodic timer can never start more work than capacity allows.

The correctness invariant: the capacity check and the slot occupation done inside `$tryToPickUpWork` run synchronously within a single, uninterrupted loop frame (ReactPHP is single threaded, no `await` in between). Therefore any number of stacked or racing polls collapse to "fill up to capacity, then bail".

Usage
-----

[](#usage)

`PollScheduler` is DI-free — instantiate it with `new` or the static `create()`factory, also from a standalone worker binary that has no Flow object management.

```
use Netlogix\JobQueue\Polling\PollScheduler;

$scheduler = PollScheduler::create(
    loop: $loop,                              // React\EventLoop\LoopInterface
    tryToPickUpWork: fn () => $this->pickUp($pool),   // picks up as much work as capacity allows
    hasCapacity: fn () => count($pool) < $parallel,   // cheap, side-effect free
    interval: 0.1,                            // baseline poll interval in seconds
);

$scheduler->start();                          // register the periodic baseline poll

// ... when a job finishes (e.g. in the process EXIT/SUCCESS/ERROR handler):
$scheduler->requestImmediatePoll();           // pick up the next job without waiting for the interval

// ... during a drain/shutdown phase:
$scheduler->stop();                           // cancel the baseline poll (does not stop the loop)
```

`$tryToPickUpWork` is responsible for respecting capacity itself. The two canonical shapes:

- **Single concurrency** (FastRabbit): `hasCapacity: fn () => count($pool) === 0`, and `tryToPickUpWork` reserves exactly one job when free.
- **N concurrency** (Scheduled): `hasCapacity: fn () => count($pool) < $parallel`, and `tryToPickUpWork` drains in a `while (count($pool) < $parallel)` loop.

The scheduler's own capacity pre-check is an early-out; the callback's internal limit is the authoritative bound.

API
---

[](#api)

- `PollScheduler::create(LoopInterface $loop, Closure $tryToPickUpWork, Closure $hasCapacity, float $interval): static`/ equivalent constructor.
- `start(): self` — register the periodic baseline poll.
- `requestImmediatePoll(): void` — request an out-of-band poll as soon as possible; coalesced to at most one pending future tick.
- `stop(): void` — cancel the baseline poll and stop picking up further work (drain phase); does not stop the event loop.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/667b5107f4c2ea180baa00166c2ee3f2a1b412ce22768d6e81bb09323d1c7fe0?d=identicon)[netlogix](/maintainers/netlogix)

![](https://www.gravatar.com/avatar/124704a0d41c6364ac5773df0c9bedc3a85f902f0826df5f12ff2a4b2a06d520?d=identicon)[paxuclus](/maintainers/paxuclus)

![](https://avatars.githubusercontent.com/u/1595908?v=4)[Stephan Schuler](/maintainers/stephanschuler)[@stephanschuler](https://github.com/stephanschuler)

---

Top Contributors

[![stephanschuler](https://avatars.githubusercontent.com/u/1595908?v=4)](https://github.com/stephanschuler "stephanschuler (2 commits)")

### Embed Badge

![Health badge](/badges/netlogix-jobqueue-polling/health.svg)

```
[![Health](https://phpackages.com/badges/netlogix-jobqueue-polling/health.svg)](https://phpackages.com/packages/netlogix-jobqueue-polling)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.5M29](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6045.5M503](/packages/illuminate-bus)[uecode/qpush-bundle

Asynchronous processing for Symfony using Push Queues

1672.5M2](/packages/uecode-qpush-bundle)[ezsystems/ezscriptmonitor-ls

eZ Publish extension that aims to avoid timeout problems and database corruption by moving long running processes from the GUI to the background.

13208.2k](/packages/ezsystems-ezscriptmonitor-ls)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
