stanley-king 3 年之前
父節點
當前提交
3c859fdd72
共有 2 個文件被更改,包括 42 次插入47 次删除
  1. 2 2
      helper/queue/iqueue.php
  2. 40 45
      rdispatcher/processor.php

+ 2 - 2
helper/queue/iqueue.php

@@ -249,9 +249,9 @@ abstract class ILooper
                             go(function ()use ($content,$num,$mem) {
                                 $start = microtime(true);
                                 Log::record("BegigGoFunction coroutin_num={$num} memory={$mem}",Log::DEBUG);
-                                $this->handle($content);
+                                $method = $this->handle($content);
                                 $use_time = microtime(true) - $start;
-                                $msg = sprintf("EndGoFunction coroutin_num={$num} memory={$mem} request_time=%.6f",$use_time);
+                                $msg = sprintf("EndGoFunction coroutin_num={$num} method={$method} memory={$mem} request_time=%.6f",$use_time);
                                 Log::record($msg,Log::DEBUG);
                             });
                         }

+ 40 - 45
rdispatcher/processor.php

@@ -8,10 +8,9 @@ class processor extends queue\ILooper
 
     public function __construct($comode = false)
     {
-        if($comode) {
+        if ($comode) {
             parent::__construct(new queue\CoDispatcherServer());
-        }
-        else {
+        } else {
             parent::__construct(new queue\DispatcherServer());
         }
         $this->mProxy = new proxy();
@@ -19,54 +18,50 @@ class processor extends queue\ILooper
 
     protected function handle($msg)
     {
-        if (!empty($msg))
+        if (empty($msg)) return '';
+
+        $method = '';
+        foreach ($msg as $key => $params)
         {
-            foreach ($msg as $key => $params)
+            if (empty($params)) continue;
+            $method = strtolower($key);
+            Log::record("processor hanlde method={$method}", Log::DEBUG);
+            try
             {
-                if (empty($params)) continue;
-                $method = strtolower($key);
-                Log::record("processor hanlde method={$method}", Log::DEBUG);
-                try
+                if ($method == 'add') {
+                    $this->mProxy->add($params);
+                }
+                elseif ($method == 'notify')
                 {
-                    if ($method == 'add') {
-                        $this->mProxy->add($params);
-                    }
-                    elseif ($method == 'notify') {
-                        $channel = $params['channel'];
-                        $input = $params['params'];
+                    $channel = $params['channel'];
+                    $input = $params['params'];
 
-                        if(empty($channel) || empty($params))
-                            return;
-                        $this->mProxy->notify($channel,$input);
-                    }
-                    elseif($method == 'notify_mechant') {
-                        $order_id = intval($params['order_id']);
-                        $manual = $params['manual'] ?? false;
-                        $this->mProxy->notify_merchant($order_id,$manual);
-                    }
-                    elseif($method == 'query') {
-                        $order_id = intval($params['order_id']);
-                        $this->mProxy->query($order_id);
-                    }
-                    elseif($method == 'manual_success') {
-                        $order_id = intval($params['order_id']);
-                        $this->mProxy->manual_success($order_id);
-                    }
-                    elseif($method == 'manual_cancel') {
-                        $order_id = intval($params['order_id']);
-                        $this->mProxy->manual_cancel($order_id);
-                    }
-                    elseif ($method == 'addthird') {
-                        $this->mProxy->addthird($params);
-                    }
-                    else {
-                        Log::record("Error Method={$method}", Log::DEBUG);
-                    }
-                }
-                catch (Exception $x) {
-                    Log::record($x->getMessage(), Log::ERR);
+                    if (empty($channel) || empty($params))
+                        return;
+                    $this->mProxy->notify($channel, $input);
+                } elseif ($method == 'notify_mechant') {
+                    $order_id = intval($params['order_id']);
+                    $manual = $params['manual'] ?? false;
+                    $this->mProxy->notify_merchant($order_id, $manual);
+                } elseif ($method == 'query') {
+                    $order_id = intval($params['order_id']);
+                    $this->mProxy->query($order_id);
+                } elseif ($method == 'manual_success') {
+                    $order_id = intval($params['order_id']);
+                    $this->mProxy->manual_success($order_id);
+                } elseif ($method == 'manual_cancel') {
+                    $order_id = intval($params['order_id']);
+                    $this->mProxy->manual_cancel($order_id);
+                } elseif ($method == 'addthird') {
+                    $this->mProxy->addthird($params);
+                } else {
+                    Log::record("Error Method={$method}", Log::DEBUG);
                 }
+            } catch (Exception $x) {
+                Log::record($x->getMessage(), Log::ERR);
             }
         }
+
+        return $method;
     }
 }