Skip to content

Commit bf045c3

Browse files
committed
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.
1 parent d67893f commit bf045c3

16 files changed

Lines changed: 55 additions & 535 deletions

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,17 @@ foreach ($userIds as $userId) {
219219

220220
## API Reference
221221

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

224224
The main dispatch function that creates a closure job.
225225

226226
**Parameters:**
227227
- `$closure` - The closure to execute
228228

229229
**Returns:**
230-
- `PendingClosureDispatch` - Pending closure dispatch object
230+
- `PendingAsyncQueueDispatch` - Pending closure dispatch object
231231

232-
### `PendingClosureDispatch` Methods
232+
### `PendingAsyncQueueDispatch` Methods
233233

234234
#### `onConnection(string $connection): static`
235235

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,17 @@ 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` 方法
232+
### `PendingAsyncQueueDispatch` 方法
233233

234234
#### `onConnection(string $connection): static`
235235

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,17 @@ 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` 方法
232+
### `PendingAsyncQueueDispatch` 方法
233233

234234
#### `onConnection(string $connection): static`
235235

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,17 @@ 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` 方法
232+
### `PendingAsyncQueueDispatch` 方法
233233

234234
#### `onConnection(string $connection): static`
235235

src/async-queue-closure-job/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ dispatch(function (UserService $userService, int $userId) {
9090

9191
## API Reference
9292

93-
### `dispatch(Closure $closure): PendingClosureDispatch`
93+
### `dispatch(Closure $closure): PendingAsyncQueueDispatch`
9494

9595
The main dispatch function that creates a closure job.
9696

97-
### `PendingClosureDispatch` Methods
97+
### `PendingAsyncQueueDispatch` Methods
9898

9999
- `onConnection(string $connection): static` - Set the connection name
100100
- `delay(int $delay): static` - Set execution delay in seconds

src/async-queue-closure-job/README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ dispatch(function (UserService $userService, int $userId) {
9090

9191
## API 参考
9292

93-
### `dispatch(Closure $closure): PendingClosureDispatch`
93+
### `dispatch(Closure $closure): PendingAsyncQueueDispatch`
9494

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

97-
### `PendingClosureDispatch` 方法
97+
### `PendingAsyncQueueDispatch` 方法
9898

9999
- `onConnection(string $connection): static` - 设置连接名称
100100
- `delay(int $delay): static` - 设置延迟执行时间(秒)

src/async-queue-closure-job/src/Functions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
namespace FriendsOfHyperf\AsyncQueueClosureJob;
1313

1414
use Closure;
15+
use FriendsOfHyperf\Support\Bus\PendingAsyncQueueDispatch;
1516

1617
/**
1718
* Dispatch a closure as an async queue job.
1819
*
1920
* @param Closure $closure The closure to execute
2021
* @param-closure-this CallQueuedClosure $closure
2122
*/
22-
function dispatch(Closure $closure): PendingClosureDispatch
23+
function dispatch(Closure $closure): PendingAsyncQueueDispatch
2324
{
24-
return new PendingClosureDispatch(
25+
return new PendingAsyncQueueDispatch(
2526
CallQueuedClosure::create($closure)
2627
);
2728
}

src/async-queue-closure-job/src/PendingClosureDispatch.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/support/src/Bus/PendingAsyncQueueDispatch.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function onPool(string $pool): static
4848
return $this;
4949
}
5050

51+
public function onConnection(string $connection): static
52+
{
53+
return $this->onPool($connection);
54+
}
55+
5156
public function delay(int $delay): static
5257
{
5358
$this->delay = $delay;

tests/AsyncQueueClosureJob/BasicFunctionalityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function testMultipleCreateCallsWithDifferentMaxAttempts()
224224
}
225225

226226
// Note: Dispatch function tests are omitted due to container configuration requirements
227-
// The functionality is tested through PendingClosureDispatch direct instantiation
227+
// The functionality is tested through PendingAsyncQueueDispatch direct instantiation
228228

229229
/**
230230
* Helper method to get protected/private property value.

0 commit comments

Comments
 (0)