diff --git a/src/Bootloader/TemporalBridgeBootloader.php b/src/Bootloader/TemporalBridgeBootloader.php index b316ebd..126ed46 100644 --- a/src/Bootloader/TemporalBridgeBootloader.php +++ b/src/Bootloader/TemporalBridgeBootloader.php @@ -8,7 +8,6 @@ use Spiral\Boot\AbstractKernel; use Spiral\Boot\Bootloader\Bootloader; use Spiral\Boot\EnvironmentInterface; -use Spiral\Boot\FinalizerInterface; use Spiral\Config\ConfiguratorInterface; use Spiral\Config\Patch\Append; use Spiral\Console\Bootloader\ConsoleBootloader; @@ -20,8 +19,6 @@ use Spiral\TemporalBridge\DeclarationLocator; use Spiral\TemporalBridge\DeclarationLocatorInterface; use Spiral\TemporalBridge\Dispatcher; -use Spiral\TemporalBridge\Preset\PresetRegistry; -use Spiral\TemporalBridge\Preset\PresetRegistryInterface; use Spiral\TemporalBridge\WorkerFactory; use Spiral\TemporalBridge\WorkerFactoryInterface; use Spiral\TemporalBridge\WorkersRegistry; @@ -55,7 +52,8 @@ public function defineDependencies(): array public function defineSingletons(): array { return [ - WorkerFactoryInterface::class => [self::class, 'initWorkerFactory'], + TemporalWorkerFactoryInterface::class => [self::class, 'initWorkerFactory'], + WorkerFactoryInterface::class => WorkerFactory::class, DeclarationLocatorInterface::class => [self::class, 'initDeclarationLocator'], WorkflowClientInterface::class => [self::class, 'initWorkflowClient'], WorkersRegistryInterface::class => WorkersRegistry::class, @@ -91,7 +89,7 @@ protected function initConfig(EnvironmentInterface $env): void [ 'address' => $env->get('TEMPORAL_ADDRESS', '127.0.0.1:7233'), 'namespace' => 'App\\Endpoint\\Temporal\\Workflow', - 'defaultWorker' => (string)$env->get('TEMPORAL_TASK_QUEUE', WorkerFactoryInterface::DEFAULT_TASK_QUEUE), + 'defaultWorker' => (string)$env->get('TEMPORAL_TASK_QUEUE', TemporalWorkerFactoryInterface::DEFAULT_TASK_QUEUE), 'workers' => [], ], ); @@ -115,18 +113,16 @@ protected function initDataConverter(): DataConverterInterface return DataConverter::createDefault(); } - protected function initWorkerFactory( - DataConverterInterface $dataConverter, - ): WorkerFactoryInterface { - return new WorkerFactory( + protected function initWorkerFactory(DataConverterInterface $dataConverter,): TemporalWorkerFactoryInterface + { + return new TemporalWorkerFactory( dataConverter: $dataConverter, rpc: Goridge::create(), ); } - protected function initDeclarationLocator( - ClassesInterface $classes, - ): DeclarationLocatorInterface { + protected function initDeclarationLocator(ClassesInterface $classes,): DeclarationLocatorInterface + { return new DeclarationLocator( classes: $classes, reader: new AttributeReader(), @@ -137,7 +133,7 @@ protected function initPipelineProvider(TemporalConfig $config, FactoryInterface { /** @var Interceptor[] $interceptors */ $interceptors = \array_map( - static fn (mixed $interceptor) => match (true) { + static fn(mixed $interceptor) => match (true) { \is_string($interceptor) => $factory->make($interceptor), $interceptor instanceof Autowire => $interceptor->resolve($factory), default => $interceptor diff --git a/tests/src/Bootloader/PrototypeBootloaderTest.php b/tests/src/Bootloader/PrototypeBootloaderTest.php deleted file mode 100644 index 0d082e7..0000000 --- a/tests/src/Bootloader/PrototypeBootloaderTest.php +++ /dev/null @@ -1,29 +0,0 @@ -getContainer()->get(PrototypeRegistry::class); - - $this->assertInstanceOf( - $expected, - $this->getContainer()->get($registry->resolveProperty($property)->type->name()) - ); - } - - public function propertiesDataProvider(): \Traversable - { - yield [WorkflowClientInterface::class, 'workflow']; - } -} diff --git a/tests/src/Bootloader/TemporalBridgeBootloaderTest.php b/tests/src/Bootloader/TemporalBridgeBootloaderTest.php index 91639f2..7c87d1d 100644 --- a/tests/src/Bootloader/TemporalBridgeBootloaderTest.php +++ b/tests/src/Bootloader/TemporalBridgeBootloaderTest.php @@ -27,6 +27,14 @@ class TemporalBridgeBootloaderTest extends TestCase { + public function testTemporalWorkerFactory(): void + { + $this->assertContainerBoundAsSingleton( + TemporalWorkerFactoryInterface::class, + TemporalWorkerFactory::class, + ); + } + public function testWorkerFactory(): void { $this->assertContainerBoundAsSingleton( @@ -39,7 +47,7 @@ public function testDataConverter(): void { $this->assertContainerBoundAsSingleton( DataConverterInterface::class, - DataConverter::class + DataConverter::class, ); } @@ -47,7 +55,7 @@ public function testDeclarationLocator(): void { $this->assertContainerBoundAsSingleton( DeclarationLocatorInterface::class, - DeclarationLocator::class + DeclarationLocator::class, ); } @@ -55,7 +63,7 @@ public function testWorkflowClient(): void { $this->assertContainerBoundAsSingleton( WorkflowClientInterface::class, - WorkflowClient::class + WorkflowClient::class, ); } @@ -63,7 +71,7 @@ public function testWorkersRegistry(): void { $this->assertContainerBoundAsSingleton( WorkersRegistryInterface::class, - WorkersRegistry::class + WorkersRegistry::class, ); } @@ -71,7 +79,7 @@ public function testPipelineProvider(): void { $this->assertContainerBound( PipelineProvider::class, - SimplePipelineProvider::class + SimplePipelineProvider::class, ); } @@ -86,7 +94,7 @@ public function testAddWorkerOptions(): void $this->assertSame( ['first' => $first, 'second' => $second], - $configs->getConfig(TemporalConfig::CONFIG)['workers'] + $configs->getConfig(TemporalConfig::CONFIG)['workers'], ); } }