folk-plugin-jobs
Queue consumer plugin for Folk — pulls jobs from memory or Redis and dispatches to PHP workers.
Configuration
Add to folk.build.toml:
[[]]
= "folk-plugin-jobs"
= "0.1"
= "jobs"
Configure in folk.toml:
[]
= "redis" # "memory" or "redis"
= "redis://127.0.0.1:6379" # only for redis driver
[[]]
= "default"
= 4
= 3
[[]]
= "emails"
= 2
= 5
Settings
[jobs]
| Key | Type | Default | Description |
|---|---|---|---|
driver |
"memory" | "redis" |
"memory" |
Queue backend. memory is in-process only (no persistence). |
redis_url |
String |
"redis://127.0.0.1:6379" |
Redis connection URL (redis driver only). |
[[jobs.queues]]
| Key | Type | Default | Description |
|---|---|---|---|
name |
String |
"default" |
Queue name. |
concurrency |
usize |
4 |
Concurrent consumer tasks for this queue. |
max_retries |
u32 |
3 |
Max retries before discarding a failed job. |
RPC methods
| Method | Description |
|---|---|
jobs.push |
Push a job to a queue. Params: {queue: string, payload: string|binary} |
jobs.stats |
Returns queue depth for each configured queue. |
Usage with folk-sdk (plain PHP)
Handler
Registration
Pushing jobs
Jobs are pushed via the Folk admin RPC socket, not directly to Redis. Use the built-in RPC client:
This works with both memory and redis drivers — your code doesn't need to know which driver is used.
Usage with Laravel (folk-laravel)
Setup
- Set queue connection in
.env:
QUEUE_CONNECTION=folk
- Add the
folkconnection toconfig/queue.php:
- Configure
rpc_socketinconfig/folk.php:
Dispatching jobs
Use standard Laravel dispatch — no changes needed:
Jobs flow through Folk transparently:
Laravel dispatch() --> FolkQueue --> RPC (jobs.push) --> folk-plugin-jobs --> [memory|redis] --> PHP worker --> fire()
Laravel serializes the job, Folk handles routing and storage. Your application code never touches Redis directly.
Job classes
Standard Laravel job classes work out of the box:
Multiple queues
Define queues in folk.toml and dispatch to them by name:
[[]]
= "default"
= 4
[[]]
= "emails"
= 2
[[]]
= "reports"
= 1
How it works
Drivers
Memory — In-process VecDeque. No persistence. Good for development and testing.
Redis — BLPOP for consumption, RPUSH for enqueue. Each queue is a Redis list key. At-least-once semantics.
Consumer loop
For each queue, the plugin spawns concurrency consumer tasks:
driver.pop(queue)— blocks until a job is available- Sends payload to PHP worker via
jobs.processRPC - On failure, retries with exponential backoff (2s, 4s, 8s, ..., max 32s)
- After
max_retriesfailures, job is discarded and logged
Push via RPC
The jobs.push RPC method accepts {queue, payload} and pushes to the configured driver. This is how FolkQueue (Laravel) and RpcClient (SDK) submit jobs without knowing the backend.
License
MIT