digiloopinc/laravel-pausable-batch
Composer 安装命令:
composer require digiloopinc/laravel-pausable-batch
包简介
A Laravel package that adds pause and resume controls to queued batch jobs.
README 文档
README
Pause and resume Laravel job batches running on Redis queues.
Warning
This package is currently under active development and is not yet considered production-stable.
When a batch is paused, workers using the redis queue driver will not execute jobs that belong to that batch. Paused jobs are parked in Redis and restored when the batch resumes.
Installation
composer require digiloopinc/laravel-pausable-batch
Queue Connection Setup
Use your standard redis queue connection:
// config/queue.php 'connections' => [ 'redis' => [ 'driver' => 'redis', 'connection' => 'default', 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90, 'block_for' => null, 'after_commit' => false, 'options' => [ 'pausable' => [ 'redis_prefix' => env('PAUSABLE_BATCH_REDIS_PREFIX', 'laravel-pausable-batch'), 'restore_chunk_size' => (int) env('PAUSABLE_BATCH_RESTORE_CHUNK_SIZE', 1000), ], ], ], ],
Then run workers against that connection:
php artisan queue:work redis
Horizon uses the same redis connection and is automatically supported.
Batch API
Batches returned from the repository are wrapped as PausableBatch and expose:
pause(): voidpaused(): boolresume(): void
use Illuminate\Support\Facades\Bus; $batch = Bus::batch([ new \App\Jobs\FirstJob(), new \App\Jobs\SecondJob(), ])->dispatch(); $batch->pause(); if ($batch->paused()) { $batch->resume(); }
Configuration
Configure pausable behavior directly on each queue connection under options.pausable:
redis_prefix: Redis key prefix for pause metadata.restore_chunk_size: Number of paused jobs restored per chunk on resume.
Pause metadata uses the same Redis connection as the queue connection's connection setting.
Behavior Notes
- Only
Batchablejobs are considered pausable. - Pause is enforced at worker pop time.
- Paused jobs are moved off the active queue into per-batch paused lists.
- Resume restores paused jobs to the tail of their original queue.
- Pause metadata and parked jobs are cleaned on resume, cancellation, and finish.
Testing
composer test
digiloopinc/laravel-pausable-batch 适用场景与选型建议
digiloopinc/laravel-pausable-batch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 115 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「digiloopinc」 「laravel-pausable-batch」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 digiloopinc/laravel-pausable-batch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 digiloopinc/laravel-pausable-batch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 115
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-09