Skip to content

Commit 718a2f7

Browse files
committed
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.
1 parent 64283e5 commit 718a2f7

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,11 @@ foreach ($userIds as $userId) {
224224
The main dispatch function that creates a closure job.
225225

226226
**Parameters:**
227+
227228
- `$closure` - The closure to execute
228229

229230
**Returns:**
231+
230232
- `PendingAsyncQueueDispatch` - Pending closure dispatch object
231233

232234
### `PendingAsyncQueueDispatch` Methods
@@ -236,61 +238,73 @@ The main dispatch function that creates a closure job.
236238
Set the queue connection name.
237239

238240
**Parameters:**
241+
239242
- `$connection` - Queue connection name
240243

241244
**Returns:**
245+
242246
- `static` - Current object for method chaining
243247

244248
#### `onPool(string $pool): static`
245249

246250
Set the queue connection name (alias for `onConnection`).
247251

248252
**Parameters:**
253+
249254
- `$pool` - Queue connection name
250255

251256
**Returns:**
257+
252258
- `static` - Current object for method chaining
253259

254260
#### `delay(int $delay): static`
255261

256262
Set the delay time before execution.
257263

258264
**Parameters:**
265+
259266
- `$delay` - Delay time in seconds
260267

261268
**Returns:**
269+
262270
- `static` - Current object for method chaining
263271

264272
#### `setMaxAttempts(int $maxAttempts): static`
265273

266274
Set the maximum retry attempts.
267275

268276
**Parameters:**
277+
269278
- `$maxAttempts` - Maximum attempts
270279

271280
**Returns:**
281+
272282
- `static` - Current object for method chaining
273283

274284
#### `when($condition, $callback): static`
275285

276286
Execute callback when condition is true.
277287

278288
**Parameters:**
289+
279290
- `$condition` - Condition expression
280291
- `$callback` - Callback function that receives the current object as parameter
281292

282293
**Returns:**
294+
283295
- `static` - Current object for method chaining
284296

285297
#### `unless($condition, $callback): static`
286298

287299
Execute callback when condition is false.
288300

289301
**Parameters:**
302+
290303
- `$condition` - Condition expression
291304
- `$callback` - Callback function that receives the current object as parameter
292305

293306
**Returns:**
307+
294308
- `static` - Current object for method chaining
295309

296310
## Supported Closure Types
@@ -375,6 +389,7 @@ dispatch(function (NotificationService $notification) use ($userId, $message) {
375389
```
376390

377391
Advantages of closure jobs:
392+
378393
- Cleaner code, no need to create extra class files
379394
- Better readability, job logic is right where it's dispatched
380395
- Full dependency injection support

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

Lines changed: 7 additions & 7 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
### 批量操作
@@ -231,7 +231,7 @@ foreach ($userIds as $userId) {
231231

232232
### `PendingAsyncQueueDispatch` 方法
233233

234-
#### `onConnection(string $connection): static`
234+
#### `onPool(string $connection): static`
235235

236236
设置队列连接名称。
237237

@@ -243,7 +243,7 @@ foreach ($userIds as $userId) {
243243

244244
#### `onPool(string $pool): static`
245245

246-
设置队列连接名称(`onConnection` 的别名)。
246+
设置队列连接名称(`onPool` 的别名)。
247247

248248
**参数:**
249249
- `$pool` - 队列连接名称

0 commit comments

Comments
 (0)