polysource/bulk-async 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

polysource/bulk-async

最新稳定版本:v0.1.2

Composer 安装命令:

composer require polysource/bulk-async

包简介

Polysource — async bulk actions via Symfony Messenger + live progress via Mercure SSE.

README 文档

README

Asynchronous bulk actions for Polysource — execute over Symfony Messenger with live progress (Mercure) and cancel mid-flight.

Part of the Polysource monorepo. MIT-licensed.

When to use

The synchronous bulk action ("Retry 5 000 failed messages") times out after 30 s in production. This package fans the work out to Messenger workers, persists per-job progress every 5 records or 500 ms, and exposes a JSON endpoint + Mercure topic so the UI can show a live progress bar and a "Cancel" button.

See ADR-024.

What it ships

  • BulkJob immutable VO (12 fields, 8 KiB error cap) + BulkJobStatus enum (5 states, isTerminal()).
  • BulkJobStorageInterface + DoctrineBulkJobStorage + Doctrine entity.
  • BulkJobMessage + BulkJobHandler — re-fetches each iteration to honour Cancelled, throttled persist (5 records OR 500 ms), per-record exception isolation.
  • AsyncBulkActionDispatcher — UUID v7 + Pending persist + Messenger dispatch.
  • AsyncAwareBulkActionInterface — opt-in marker (parallel interface, no BC break to BulkActionInterface).
  • BulkJobResource — browsable admin resource (#[AsResource], slug bulk-jobs).
  • CancelBulkJobAction — idempotent on terminal, gated POLYSOURCE_BULK_JOB_CANCEL.
  • ProgressController — JSON GET /admin/bulk-jobs/{id}/progress. Two-stage gate: coarse POLYSOURCE_BULK_JOB_VIEW permission + ownership check (requester must own the job, or hold POLYSOURCE_BULK_JOB_VIEW_ANY).
  • MercureBulkJobBroadcaster — gated on class_exists(HubInterface), hub failures swallowed, topic polysource/bulk-jobs/{actorId}/{id} (actor segment URL-encoded). Pair with the polysource_bulk_progress_topic(job) Twig helper so client and broadcaster always agree on the topic shape; configure your Mercure JWT subscriber claims to restrict per-actor for defence-in-depth.
  • Stimulus progress_controller.js — EventSource Mercure → polling fallback auto on error.

Install

composer require polysource/bulk-async symfony/messenger
# Optional but recommended for live progress:
composer require symfony/mercure-bundle

Register the bundle:

return [
    Polysource\BulkAsync\PolysourceBulkAsyncBundle::class => ['all' => true],
];

Run the migration to create polysource_bulk_jobs.

Extend it

BulkJobStorageInterface is 3 methods. To persist jobs in Redis / Mongo / your service instead of Doctrine, implement it and alias the interface to your service in DI. The handler, the ProgressController, the Mercure broadcaster all keep working.

See extensibility map.

Documentation

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固