swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 786 forks source link

swoft/breaker high weight bug #1406

Open easyphplib opened 3 years ago

easyphplib commented 3 years ago
Q A
Bug report? yes
Feature request? no
Swoft version 2.0
Swoole version 4.5
PHP version 7.2.34
Runtime environment centos 7

Describe the bug when use broker on service return too slow, then it happend return Error!!! just like this: Return value of App\Rpc\Lib\UserInterface_IGNORE_5fe2a4025d599::delete() must be of the type boolean, array returned

Expected behavior quckly click refresh browser, it happend.

Screenshots Return value of App\Rpc\Lib\UserInterface_IGNORE_5fe2a4025d599::delete() must be of the type boolean, array returned

Details

Describe what you are trying to achieve and what goes wrong.

  /**
     * 获取列表
     * @Breaker(fallback="testList")
     *
     * @param int   $id
     * @param mixed $type
     * @param int   $count
     *
     * @return array
     */
    public function getList(int $id, $type, int $count = 10): array
    {
        echo 'getList->[]'."\n";
        return [];

    }

    public function testList(int $id, $type, int $count = 10)
    {
        echo 'getList->testList->[]'."\n";
        return [];
    }

  /**
     * 删除
     *
     * @Breaker(fallback="testDelete")
     *
     * @param int $id
     *
     * @return mixed
     */
    public function delete(int $id, $isSleep=0) :bool
    {
        throw new \Exception('test');
        echo 'xxxxxxxxxxxxxxxxxx->error';
        return false;

    }

    /**
     * @return int
     */
    public function testDelete(int $id, $isSleep=0) :bool
    {

        echo 'delete->testDelete->';
        if($isSleep){
            echo "\n";
        }
        $isSleep && sleep($isSleep);
        echo 'false'."\n";
        return false;

    }

Provide minimal script to reproduce the issue

        $res['r4'] = $this->userService->delete(12, 0);
        $res['r5'] = $this->userService->delete(12, 5);
        $res['r7'] = $this->userService->getList(12, 'type');