From f6de929a67a272a33ad873ae0216065122820435 Mon Sep 17 00:00:00 2001
From: Dmitrii Derepko <xepozz@list.ru>
Date: Sat, 14 Dec 2024 15:34:08 +0300
Subject: [PATCH] move bridge params to the package

---
 config/di-temporal.php | 28 +++++++++++++++++++++++++---
 config/params.php      |  1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/config/di-temporal.php b/config/di-temporal.php
index 4dde944..11fdd2b 100644
--- a/config/di-temporal.php
+++ b/config/di-temporal.php
@@ -2,6 +2,10 @@
 
 declare(strict_types=1);
 
+use Temporal\Client\GRPC\ServiceClient;
+use Temporal\Client\GRPC\ServiceClientInterface;
+use Temporal\Client\WorkflowClient;
+use Temporal\Client\WorkflowClientInterface;
 use Temporal\DataConverter\DataConverter;
 use Temporal\DataConverter\DataConverterInterface;
 use Temporal\Worker\Transport\Goridge;
@@ -10,6 +14,7 @@
 use Temporal\Worker\Transport\RPCConnectionInterface;
 use Temporal\Worker\WorkerFactoryInterface;
 use Temporal\WorkerFactory;
+use Yiisoft\Definitions\Reference;
 use Yiisoft\Yii\Runner\RoadRunner\Temporal\TemporalDeclarationProvider;
 
 /**
@@ -22,11 +27,28 @@
 }
 
 return [
-    DataConverterInterface::class => fn () => DataConverter::createDefault(),
-    RPCConnectionInterface::class => fn () => Goridge::create(),
+    DataConverterInterface::class => DataConverter::class,
+    DataConverter::class => fn () => DataConverter::createDefault(),
+
+    RPCConnectionInterface::class => Goridge::class,
+    Goridge::class => fn () => Goridge::create(),
+
     WorkerFactoryInterface::class => WorkerFactory::class,
     WorkerFactory::class => fn () => WorkerFactory::create(),
-    HostConnectionInterface::class => fn () => RoadRunner::create(),
+
+    HostConnectionInterface::class => RoadRunner::class,
+    RoadRunner::class => fn () => RoadRunner::create(),
+
+    WorkflowClientInterface::class => WorkflowClient::class,
+    WorkflowClient::class => [
+        'class' => WorkflowClient::class,
+        '__construct()' => [
+            Reference::to(ServiceClientInterface::class),
+        ],
+    ],
+
+    ServiceClientInterface::class => ServiceClient::class,
+    ServiceClient::class => fn () => ServiceClient::create($temporalParams['host']),
 
     TemporalDeclarationProvider::class => fn () => new TemporalDeclarationProvider(
         $temporalParams['workflows'] ?? [],
diff --git a/config/params.php b/config/params.php
index fc2223b..d6540fa 100644
--- a/config/params.php
+++ b/config/params.php
@@ -9,6 +9,7 @@
         ],
         'temporal' => [
             'enabled' => false,
+            'host' => 'localhost:7233',
             'workflows' => [],
             'activities' => [],
         ],