Просмотр исходного кода

rpc.host 拆分为 host and port

visuddhinanda 2 лет назад
Родитель
Сommit
c2c4427ce8
4 измененных файлов с 27 добавлено и 26 удалено
  1. 1 1
      app/Tools/Export.php
  2. 1 1
      app/Tools/Markdown.php
  3. 9 17
      app/Tools/PaliSearch.php
  4. 16 7
      config/mint.php

+ 1 - 1
app/Tools/Export.php

@@ -17,7 +17,7 @@ class Export
             //Log::info($value['name']);
             //Log::info($value['content']);
         }
-        $host = config('mint.server.rpc.lily');
+        $host = config('mint.server.rpc.lily.host') . '/' . config('mint.server.rpc.lily.port');
         $client = new \Palm\Lily\V1\TexClient($host, [
             'credentials' => \Grpc\ChannelCredentials::createInsecure(),
         ]);

+ 1 - 1
app/Tools/Markdown.php

@@ -28,7 +28,7 @@ class Markdown
     }
 
     public static function morus($text){
-        $host = config('mint.server.rpc.morus');
+        $host = config('mint.server.rpc.morus.host') . '/'. config('mint.server.rpc.morus.port');
         Log::debug('morus host='.$host);
         $client = new \Mint\Morus\V1\MarkdownClient($host, [
             'credentials' => \Grpc\ChannelCredentials::createInsecure(),

+ 9 - 17
app/Tools/PaliSearch.php

@@ -5,12 +5,16 @@ use Illuminate\Support\Facades\Log;
 
 class PaliSearch
 {
-    public static function search($words,$books,$matchMode='case',$index=0,$size=10){
-        $host = config('mint.server.rpc.tulip');
+    public static function connect(){
+        $host = config('mint.server.rpc.tulip.host') . '/' . config('mint.server.rpc.tulip.port');
         Log::debug('tulip host='.$host);
         $client = new \Mint\Tulip\V1\SearchClient($host, [
             'credentials' => \Grpc\ChannelCredentials::createInsecure(),
         ]);
+        return $client;
+    }
+    public static function search($words,$books,$matchMode='case',$index=0,$size=10){
+        $client = PaliSearch::connect();
 
         $request = new \Mint\Tulip\V1\SearchRequest();
         $request->setKeywords($words);
@@ -42,11 +46,7 @@ class PaliSearch
     }
 
     public static function book_list($words,$books,$matchMode='case',$index=0,$size=10){
-        $host = config('mint.server.rpc.tulip');
-        Log::debug('tulip host='.$host);
-        $client = new \Mint\Tulip\V1\SearchClient($host, [
-            'credentials' => \Grpc\ChannelCredentials::createInsecure(),
-        ]);
+        $client = PaliSearch::connect();
 
         $request = new \Mint\Tulip\V1\SearchRequest();
         $request->setKeywords($words);
@@ -74,11 +74,7 @@ class PaliSearch
     }
 
     public static function upload_dict($data){
-        $host = config('mint.server.rpc.tulip');
-        Log::debug('tulip host='.$host);
-        $client = new \Mint\Tulip\V1\SearchClient($host, [
-            'credentials' => \Grpc\ChannelCredentials::createInsecure(),
-        ]);
+        $client = PaliSearch::connect();
 
         $request = new \Mint\Tulip\V1\UploadDictionaryRequest();
         $request->setData($data);
@@ -94,11 +90,7 @@ class PaliSearch
     public static function update($book,$paragraph,
                                   $bold1,$bold2,$bold3,
                                   $content,$pcd_book_id){
-        $host = config('mint.server.rpc.tulip');
-        Log::debug('tulip host='.$host);
-        $client = new \Mint\Tulip\V1\SearchClient($host, [
-            'credentials' => \Grpc\ChannelCredentials::createInsecure(),
-        ]);
+        $client = PaliSearch::connect();
 
         $request = new \Mint\Tulip\V1\UpdateRequest();
         $request->setBook($book);

+ 16 - 7
config/mint.php

@@ -15,13 +15,22 @@ return [
 
     'server' => [
         'rpc' => [
-            'grpc' => env('GRPC_WEB_SERVER', "http://localhost:9999"),
-
-            'morus' => env('MORUS_GRPC_SERVER', "http://localhost:9999"),
-
-            'lily' => env('LILY_GRPC_SERVER', "http://localhost:9000"),
-
-            'tulip' => env('TULIP_GRPC_SERVER', "http://localhost:9990"),
+            'grpc' =>  env('GRPC_WEB_SERVER', "http://localhost:9999"),
+
+            'morus' => [
+                'host' => env('MORUS_GRPC_HOST', "http://localhost"),
+                'port' => env('MORUS_GRPC_PORT', 9999),
+            ],
+
+            'lily' => [
+                'host' => env('LILY_GRPC_HOST', "http://192.168.43.100"),
+                'port' => env('LILY_GRPC_PORT', 9000),
+            ],
+
+            'tulip' => [
+                'host' => env('LILY_GRPC_HOST', "http://localhost"),
+                'port' => env('LILY_GRPC_PORT', 9990),
+            ],
         ],
 
         'assets' => env('ASSETS_SERVER', "localhost:9999"),