Home > Enterprise >  Laravel/Octane - How to set timeout on concurrently method?
Laravel/Octane - How to set timeout on concurrently method?

Time:10-05

Is it possible to set timeout on Octane::concurrently ?

Octane::concurrently([
    fn () => User::all(),
    fn () => Server::all(),
    fn () => Model::all(),
    //...

]);

As you can see i have mutiple eloquent operation so its possible one of them take too long to execute, So i want to know is it possible to set timeout on this method?

CodePudding user response:

The second parameter of the Octane::concurrently method is the timeout in miliseconds:

Octane::concurrently([
    fn () => User::all(),
    fn () => Server::all(),
    fn () => Model::all(),
    //...

], 5000);

See:
https://github.com/laravel/octane/blob/1.x/src/Contracts/DispatchesTasks.php#L19 https://github.com/laravel/octane/blob/1.x/src/Swoole/SwooleTaskDispatcher.php#L27 https://github.com/laravel/octane/blob/1.x/src/Swoole/SwooleHttpTaskDispatcher.php#L36 https://github.com/laravel/octane/blob/1.x/src/SequentialTaskDispatcher.php#L23

  • Related