|
25 | 25 | use Temporal\Internal\Marshaller\Marshaller; |
26 | 26 | use Temporal\Internal\Marshaller\MarshallerInterface; |
27 | 27 | use Temporal\Internal\ServiceContainer; |
| 28 | +use Temporal\Worker\Environment\Environment; |
| 29 | +use Temporal\Worker\Environment\EnvironmentInterface; |
28 | 30 | use Temporal\Worker\Transport\Codec\CodecInterface; |
29 | 31 | use Temporal\Internal\Events\EventEmitterTrait; |
30 | 32 | use Temporal\Internal\Queue\ArrayQueue; |
|
52 | 54 |
|
53 | 55 | /** |
54 | 56 | * WorkerFactory is primary entry point for the temporal application. This class is responsible for the communication |
55 | | - * with parent RoadRunnner process and can be used to create taskQueue workflow and activity workers. |
| 57 | + * with parent RoadRunner process and can be used to create taskQueue workflow and activity workers. |
56 | 58 | * |
57 | 59 | * <code> |
58 | 60 | * $factory = WorkerFactory::create(); |
@@ -150,6 +152,11 @@ final class WorkerFactory implements WorkerFactoryInterface, LoopInterface |
150 | 152 | */ |
151 | 153 | private MarshallerInterface $marshaller; |
152 | 154 |
|
| 155 | + /** |
| 156 | + * @var EnvironmentInterface |
| 157 | + */ |
| 158 | + private EnvironmentInterface $env; |
| 159 | + |
153 | 160 | /** |
154 | 161 | * @param DataConverterInterface $dataConverter |
155 | 162 | * @param RPCConnectionInterface $rpc |
@@ -235,6 +242,14 @@ public function getMarshaller(): MarshallerInterface |
235 | 242 | return $this->marshaller; |
236 | 243 | } |
237 | 244 |
|
| 245 | + /** |
| 246 | + * @return EnvironmentInterface |
| 247 | + */ |
| 248 | + public function getEnviroment(): EnvironmentInterface |
| 249 | + { |
| 250 | + return $this->env; |
| 251 | + } |
| 252 | + |
238 | 253 | /** |
239 | 254 | * {@inheritDoc} |
240 | 255 | */ |
@@ -277,6 +292,7 @@ private function boot(): void |
277 | 292 | $this->responses = $this->createQueue(); |
278 | 293 | $this->client = $this->createClient(); |
279 | 294 | $this->server = $this->createServer(); |
| 295 | + $this->env = new Environment(); |
280 | 296 | } |
281 | 297 |
|
282 | 298 | /** |
@@ -375,6 +391,7 @@ private function createCodec(): CodecInterface |
375 | 391 | private function dispatch(string $messages, array $headers): string |
376 | 392 | { |
377 | 393 | $commands = $this->codec->decode($messages); |
| 394 | + $this->env->update($headers); |
378 | 395 |
|
379 | 396 | foreach ($commands as $command) { |
380 | 397 | if ($command instanceof RequestInterface) { |
|
0 commit comments