garveen/laravoole

Is it possible to add some hooks when worker process deal with onReqeust method?

Closed this issue · 3 comments

// vendor/garveen/laravoole/src/Base.php
......
$kernel = $this->kernel;

// do some others action before deal request
if (isset($this->wrapper_config['on_before_deal_request_cb']) && Arr::accessible($this->wrapper_config['on_before_deal_request_cb'])) {
    $dealActions = $this->wrapper_config['on_before_deal_request_cb'];
    foreach ($dealActions as $action) {
        if (is_callable($action)) {
            call_user_func($action, [$this->app]);
        }
    }
}

if (!$illuminate_request) {
    $illuminate_request = $this->dealWithRequest($request);
}
......

Is it possible to add some hooks when worker process deal with onReqeust method?

Thanks author to offer this nice package. Ur... Can you speak Chinese?

Is it possible to add some hooks when worker process deal with onReqeust method?

Now it is possible by using laravel's events mechanism.

Can you speak Chinese?

Yes.

我目前打算在已有的laravel框架上整合laravoole,但是我发现有部分包,比如tymon/jwt-auth,会出现缓存前一个request中的数据的现象...... 就像laravel auth一样,需要在onRequest后释放......

所以能否在onRequest中提供两个hook或者event,让用户重新register或者boot某一个服务成为可能吗?

还有我刚才想重写部分类函数,发现:

// 保护方法
protected function dealWithRequest($request, $classname = IlluminateRequest::class)

// 私有方法
private function dealWithResponse($response, $illuminate_response, $accept_gzip)

不知道出于何原因,dealWithReponse方法是私有的...... 我重写失败了~

刚开始用swoole,之前找了好几个swoole + laravel整合,就属这个最好。

谢谢作者,希望能把这个越做越好,可能会成为最好的swoole + laravel,标杆吧。

master中已经有laravoole.on_request事件。

如无必要,一般成员可见性都是设为最低的。