예제 #1
0
 protected function checkResult(\FutoIn\AsyncSteps $as, RequestInfo $reqinfo)
 {
     if (!$this->development_checks) {
         return;
     }
     $rsp = $reqinfo->{RequestInfo::INFO_RAW_RESPONSE};
     $finfo = $as->_futoin_func_info;
     // Check raw result
     if ($finfo->rawresult) {
         if (count(get_object_vars($rsp->r))) {
             $as->error(\FutoIn\Error::InternalError, "Raw result is expected");
         }
         return;
     }
     // check result variables
     if (isset($finfo->result)) {
         $resvars = $finfo->result;
         // NOTE: the must be no unknown result variables on executor side as exactly the
         // specified interface version must be implemented
         foreach ($rsp->r as $k => $v) {
             if (!isset($resvars[$k])) {
                 $as->error(\FutoIn\Error::InternalError, "Unknown result variable '{$k}'");
             }
             SpecTools::checkFutoInType($as, $resvars[$k]->type, $k, $v);
             unset($resvars[$k]);
         }
         if (count($resvars)) {
             $as->error(\FutoIn\Error::InternalError, "Missing result variables");
         }
     } elseif (count(get_object_vars($rsp->r))) {
         $as->error(\FutoIn\Error::InternalError, "No result variables are expected");
     }
 }
 public function onMessageResponse(\FutoIn\AsyncSteps $as, $ctx, $rsp)
 {
     $info = $ctx->info;
     $func_info = $info->funcs[$ctx->name];
     // Check for exception
     if (isset($rsp->e)) {
         $error = $rsp->e;
         if (isset($func_info->throws[$error]) || isset(SpecTools::$standard_errors[$error])) {
             $as->error($error, "Executor-generated error");
         } else {
             $as->error(\FutoIn\Error::InternalError, "Not expected exception from Executor");
         }
     }
     // Check raw result
     if ($func_info->rawresult) {
         $as->error(\FutoIn\Error::InternalError, "Raw result is expected");
     }
     // Check signature
     if ($info->creds === 'master') {
         // TODO: check signature
     }
     // check result variables
     if (isset($func_info->result)) {
         $resvars = $func_info->result;
         // NOTE: by forward compatibility and inheritance requirements, unknown result variables are allowed
         foreach ($rsp->r as $k => $v) {
             if (isset($resvars[$k])) {
                 SpecTools::checkFutoInType($as, $resvars[$k]->type, $k, $v);
                 unset($resvars[$k]);
             }
         }
         if (count($resvars)) {
             $as->error(\FutoIn\Error::InternalError, "Missing result variables");
         }
         // Success
         $as->success($rsp->r);
     } else {
         $as->success();
     }
 }