diff options
author | Valery Piashchynski <[email protected]> | 2021-02-02 00:56:49 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-02-02 00:56:49 +0300 |
commit | 6d48d31ac7fb6b7a9170f2f253e204521f244c9e (patch) | |
tree | ac64346997b307808d8a6624dcd1a5a7b2e887f1 /tests | |
parent | 7149a8ee1c0935bb5c8d13312ba66b78b9c4d174 (diff) |
Update RPC plugin, use hashmap instead of slice to store pluggable
plugins
Fix issue with log channels
Diffstat (limited to 'tests')
-rw-r--r-- | tests/worker.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/worker.php b/tests/worker.php new file mode 100644 index 00000000..5c9c80e6 --- /dev/null +++ b/tests/worker.php @@ -0,0 +1,34 @@ +<?php + +declare(strict_types=1); + +require __DIR__ . '/vendor/autoload.php'; + +/** + * @param string $dir + * @return array<string> + */ +$getClasses = static function (string $dir): iterable { + $files = glob($dir . '/*.php'); + + foreach ($files as $file) { + yield substr(basename($file), 0, -4); + } +}; + +$factory = \Temporal\WorkerFactory::create(); + +$worker = $factory->newWorker('default'); + +// register all workflows +foreach ($getClasses(__DIR__ . '/src/Workflow') as $name) { + $worker->registerWorkflowTypes('Temporal\\Tests\\Workflow\\' . $name); +} + +// register all activity +foreach ($getClasses(__DIR__ . '/src/Activity') as $name) { + $class = 'Temporal\\Tests\\Activity\\' . $name; + $worker->registerActivityImplementations(new $class); +} + +$factory->run(); |