diff options
author | Valery Piashchynski <[email protected]> | 2021-09-10 15:46:02 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-09-10 15:46:02 +0300 |
commit | 8fa86886bd5b3c12cf161fb2c1cdd9a2cd53d1bf (patch) | |
tree | 852269ac09c0bcefba6e508fc04263dc061fa87b /docs/workflow/worker.md | |
parent | 8b70fb48b2b0a9451d9b82a17ac2f4cd8a1f561e (diff) |
Remove docs
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'docs/workflow/worker.md')
-rw-r--r-- | docs/workflow/worker.md | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/docs/workflow/worker.md b/docs/workflow/worker.md deleted file mode 100644 index 6a9b5a3a..00000000 --- a/docs/workflow/worker.md +++ /dev/null @@ -1,59 +0,0 @@ -# Temporal Worker -Unlike HTTP, Temporal use different way to configure a worker. Make sure to require PHP SDK: - -``` -$ composer require temporal/sdk -``` - -The worker file will look as following: - -```php -<?php - -declare(strict_types=1); - -use Temporal\WorkerFactory; - -ini_set('display_errors', 'stderr'); -include "vendor/autoload.php"; - -// factory initiates and runs task queue specific activity and workflow workers -$factory = WorkerFactory::create(); - -// Worker that listens on a task queue and hosts both workflow and activity implementations. -$worker = $factory->newWorker( - 'taskQueue', - \Temporal\Worker\WorkerOptions::new()->withMaxConcurrentActivityExecutionSize(10) -); - -// Workflows are stateful. So you need a type to create instances. -$worker->registerWorkflowTypes(MyWorkflow::class); - -// Activities are stateless and thread safe. So a shared instance is used. -$worker->registerActivityImplementations(new MyActivity()); - - -// start primary loop -$factory->run(); -``` - -Read more about temporal configuration and usage [at official website](https://docs.temporal.io/docs/php-sdk-overview). - -## Multi-worker Environment -To serve both HTTP and Temporal from the same worker use `getMode()` option of `Environment`: - -```php -use Spiral\RoadRunner; - -$rrEnv = RoadRunner\Environment::fromGlobals(); - -if ($rrEnv->getMode() === RoadRunner\Environment\Mode::MODE_TEMPORAL) { - // start temporal worker - return; -} - -if ($rrEnv->getMode() === RoadRunner\Environment\Mode::MODE_HTTP) { - // start http worker - return; -} -```
\ No newline at end of file |