Package Data | |
---|---|
Maintainer Username: | per3evere |
Maintainer Contact: | wu543065657@163.com (Persevere Von) |
Package Create Date: | 2017-06-12 |
Package Last Update: | 2021-03-19 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:16:28 |
Package Statistics | |
---|---|
Total Downloads: | 2,878 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 7 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Preq is a latency and fault tolerance library for Laravel && Lumen, inspired by Netflix’s Hystrix and upwork/phystrix
Require this package with composer:
composer require per3evere/preq --dev
Add ServiceProvider
add this to the providers array in config/app.php
Per3evere\Preq\PreqServiceProvider::class
add this in bootstrap/app.php
$app->register(Per3evere\Preq\PreqServiceProvider::class);
Create service command file
namespace App\Services;
use Per3evere\Preq\AbstractCommand;
class Example extends AbstractCommand
{
/**
* 同步执行命令.
*
* @return void
*/
public function run()
{
return 'run!';
}
/**
* 异步执行命令.
*
* @return \Guzzlehttp\Promise\Promise;
*/
public function runAsync()
{
// 返回注意返回类型.
}
}
execute it
$command = app('preq')->getCommand(\App\Services\Example::class);
// 同步执行命令
echo $command->execute();
// 异步执行命令
$command->queue();