Skip to content

Commit 614f004

Browse files
authored
refactor: remove unused PendingClosureDispatch class (#1001)
* refactor: remove unused PendingClosureDispatch class - Remove `PendingClosureDispatch` class in favor of `PendingAsyncQueueDispatch` - Add `onConnection()` alias method to `PendingAsyncQueueDispatch` for backward compatibility - Update all documentation to reference `PendingAsyncQueueDispatch` - Update test files to use `PendingAsyncQueueDispatch` and correct property references - Remove dedicated `PendingClosureDispatch` test files This change simplifies the codebase by using the shared `PendingAsyncQueueDispatch` class from the Support package, eliminating code duplication while maintaining the same functionality and API compatibility. * Update docs and translate * Remove onConnection method in PendingAsyncQueueDispatch The onConnection method was removed from PendingAsyncQueueDispatch in favor of using onPool directly. All test cases have been updated to replace onConnection calls with onPool to maintain consistency and avoid method duplication. * Update docs to use onPool instead of onConnection Replaces all instances of the onConnection method with onPool in async queue closure job documentation for consistency with the latest API usage. * Update async queue closure job docs for method naming Replaces references to `onConnection` with `onPool` in the Chinese documentation for consistency with the API. Adds formatting improvements to the English documentation for better readability. * Replace onConnection with onPool in async queue docs Updated documentation to use the onPool method instead of onConnection for specifying queue connections, reflecting API changes and improving consistency in examples and method descriptions. * Update docs and translate * Update async queue job docs to use onPool method Replaces references and documentation for the onConnection method with onPool in all language versions. Clarifies that onPool sets the queue connection name and removes duplicate/alias documentation for consistency. * Update docs and translate * 删除 AsyncQueueClosureJob 相关的测试文件以简化代码库 * 添加 AsyncQueueClosureJob 的功能测试,验证 dispatch 方法及其链式调用 --------- Co-authored-by: Deeka Wong <[email protected]>
1 parent d67893f commit 614f004

File tree

18 files changed

+287
-1924
lines changed

18 files changed

+287
-1924
lines changed

docs/en/components/async-queue-closure-job.md

Lines changed: 77 additions & 87 deletions
Large diffs are not rendered by default.

docs/zh-cn/components/async-queue-closure-job.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use function FriendsOfHyperf\AsyncQueueClosureJob\dispatch;
5151
dispatch(function () {
5252
// 你的任务逻辑
5353
})
54-
->onConnection('high-priority') // 指定队列连接
54+
->onPool('high-priority') // 指定队列连接
5555
->delay(60) // 延迟 60 秒执行
5656
->setMaxAttempts(5); // 最多重试 5 次
5757
```
@@ -66,7 +66,7 @@ use function FriendsOfHyperf\AsyncQueueClosureJob\dispatch;
6666
// 使用指定的队列连接
6767
dispatch(function () {
6868
// 高优先级任务逻辑
69-
})->onConnection('high-priority');
69+
})->onPool('high-priority');
7070

7171
// 或者使用 onPool 方法(别名)
7272
dispatch(function () {
@@ -106,7 +106,7 @@ dispatch(function () {
106106
// 你的任务逻辑
107107
})
108108
->when($isUrgent, function ($dispatch) {
109-
$dispatch->onConnection('urgent');
109+
$dispatch->onPool('urgent');
110110
});
111111

112112
// 仅当条件为 false 时执行回调
@@ -122,7 +122,7 @@ dispatch(function () {
122122
// 你的任务逻辑
123123
})
124124
->when($isUrgent, function ($dispatch) {
125-
$dispatch->onConnection('urgent');
125+
$dispatch->onPool('urgent');
126126
})
127127
->unless($isUrgent, function ($dispatch) {
128128
$dispatch->delay(60);
@@ -200,7 +200,7 @@ use function FriendsOfHyperf\AsyncQueueClosureJob\dispatch;
200200
dispatch(function (StatisticsService $stats) use ($date) {
201201
$stats->calculateDailyReport($date);
202202
$stats->sendReport($date);
203-
})->onConnection('statistics');
203+
})->onPool('statistics');
204204
```
205205

206206
### 批量操作
@@ -219,31 +219,21 @@ foreach ($userIds as $userId) {
219219

220220
## API 参考
221221

222-
### `dispatch(Closure $closure): PendingClosureDispatch`
222+
### `dispatch(Closure $closure): PendingAsyncQueueDispatch`
223223

224224
主要的分发函数,用于创建闭包任务。
225225

226226
**参数:**
227227
- `$closure` - 要执行的闭包
228228

229229
**返回:**
230-
- `PendingClosureDispatch` - 待处理的闭包分发对象
230+
- `PendingAsyncQueueDispatch` - 待处理的闭包分发对象
231231

232-
### `PendingClosureDispatch` 方法
233-
234-
#### `onConnection(string $connection): static`
235-
236-
设置队列连接名称。
237-
238-
**参数:**
239-
- `$connection` - 队列连接名称
240-
241-
**返回:**
242-
- `static` - 当前对象,支持链式调用
232+
### `PendingAsyncQueueDispatch` 方法
243233

244234
#### `onPool(string $pool): static`
245235

246-
设置队列连接名称`onConnection` 的别名)
236+
设置队列连接名称。
247237

248238
**参数:**
249239
- `$pool` - 队列连接名称

0 commit comments

Comments
 (0)