https://github.com/mix-php/micro-hystrix/blob/master/src/CircuitBreaker.php
第106行好像對(duì)并發(fā)沒效果的
// 最大并發(fā)數(shù),超過并發(fā)返回錯(cuò)誤
'maxConcurrentRequests' => 5,
這個(gè)屬性沒有用
改成1就會(huì)進(jìn)入錯(cuò)誤信息
這個(gè)不知道哦 !只是在網(wǎng)上抄襲了節(jié)流, 不知道怎么去弄 ,這個(gè)是我在網(wǎng)上抄的 不知道怎么整合到webman了
$host = request()->host();
// 健康檢查
$healthStats = new HealthStats($host, 10, 0.8);
// 熔斷器
$circuitBreaker = new CircuitBreaker($healthStats, 6, 3);
for ($i = 0; $i < 10; ++$i) {
if (!$circuitBreaker->isBreak()) {
$resp = rand(0, 10); // 模擬調(diào)用成功/失敗
if ($resp == 0) {
$healthStats->fail();
} else {
$healthStats->success();
}
} else {
$msg = "觸發(fā)熔斷機(jī)制";
return json(['code' => 500, 'msg' => $msg]);
}
}