Skip to content

Commit e4525f8

Browse files
committed
Third Readme fix iteration
1 parent d191d58 commit e4525f8

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,19 @@ Start the Temporal dev server:
267267

268268
## Custom Workers
269269

270-
As you can see, there are several predefined workers for HTTP, Jobs, gRPC, and Temporal in `'workers'` section of `config/roadrunner.php`.
271-
You can replace them with your own implementations if needed or create your own workers for other plugins, for example,
272-
for [Centrifugo](https://docs.roadrunner.dev/docs/plugins/centrifuge), [TCP](https://docs.roadrunner.dev/docs/plugins/tcp)
273-
or any other plugin.
270+
The RoadRunner Laravel Bridge comes with several predefined workers for common plugins,
271+
but you can easily create your own custom workers for any RoadRunner plugin.
272+
This section explains how to create and register custom workers in your application.
273+
274+
### Understanding Workers
275+
276+
Workers are responsible for handling requests from the RoadRunner server and processing them in your Laravel application.
277+
The predefined workers are configured in the `config/roadrunner.php` file:
274278

275279
```php
276280
return [
281+
// ... other configuration options ...
282+
277283
'workers' => [
278284
Mode::MODE_HTTP => HttpWorker::class,
279285
Mode::MODE_JOBS => QueueWorker::class,
@@ -283,7 +289,10 @@ return [
283289
];
284290
```
285291

286-
To create your own custom workers start from implementing the `Spiral\RoadRunnerLaravel\WorkerInterface`:
292+
### Creating Custom Workers
293+
294+
To create a custom worker, you need to implement the `Spiral\RoadRunnerLaravel\WorkerInterface`.
295+
This interface has a single method, `start()`, which is called when the worker is started by the RoadRunner server:
287296

288297
```php
289298
namespace App\Workers;
@@ -300,12 +309,21 @@ class CustomWorker implements WorkerInterface
300309
}
301310
```
302311

303-
Then register it in the `config/roadrunner.php`:
312+
### Registering Custom Workers
313+
314+
After creating your custom worker, you need to register it in the `config/roadrunner.php` file:
304315

305316
```php
306317
return [
318+
// ... other configuration options ...
319+
307320
'workers' => [
308-
'custom' => \App\Workers\CustomWorker::class,
321+
// Existing workers
322+
Mode::MODE_HTTP => HttpWorker::class,
323+
Mode::MODE_JOBS => QueueWorker::class,
324+
325+
// Your custom worker for a custom or built-in plugin
326+
'custom_plugin' => \App\Workers\CustomWorker::class,
309327
],
310328
];
311329
```

0 commit comments

Comments
 (0)