改名
This commit is contained in:
@@ -28,11 +28,6 @@ class Redis implements StopHeartbeatCheck
|
||||
private int $_transaction = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @var EventProvider
|
||||
*/
|
||||
private EventProvider $eventProvider;
|
||||
|
||||
private int $_timer = -1;
|
||||
|
||||
private int $_last = 0;
|
||||
@@ -51,14 +46,12 @@ class Redis implements StopHeartbeatCheck
|
||||
public string $auth = '', public string $prefix = '', public int $timeout = 30,
|
||||
public int $read_timeout = 30)
|
||||
{
|
||||
$this->eventProvider = Kiri::getDi()->get(EventProvider::class);
|
||||
}
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->heartbeat_check();
|
||||
$this->eventProvider->on(OnWorkerExit::class, [$this, 'stopHeartbeatCheck']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -218,6 +218,13 @@ class Pool extends Component
|
||||
if (!isset(static::$_connections[$name])) {
|
||||
return;
|
||||
}
|
||||
/** @var Channel|SplQueue $connection */
|
||||
foreach (static::$_connections[$name] as $connection) {
|
||||
$client = $connection->pop();
|
||||
if ($client instanceof StopHeartbeatCheck) {
|
||||
$client->stopHeartbeatCheck();
|
||||
}
|
||||
}
|
||||
static::$_connections[$name] = null;
|
||||
unset(static::$_connections[$name]);
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Annotation;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Kiri;
|
||||
use Server\Events\OnWorkerExit;
|
||||
|
||||
/**
|
||||
* Class LocalService
|
||||
* @package Annotation
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)] class LocalService extends Attribute
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* LocalService constructor.
|
||||
* @param string $service
|
||||
* @param array|null $args
|
||||
* @param bool $async_reload
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(public string $service, public ?array $args = [], public bool $async_reload = true)
|
||||
{
|
||||
if ($this->async_reload !== true) {
|
||||
$pro = di(EventProvider::class);
|
||||
$pro->on(OnWorkerExit::class, function () {
|
||||
di(\Kiri\Di\LocalService::class)->remove($this->service);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $method
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
{
|
||||
$class = ['class' => $class];
|
||||
if (!empty($this->args)) {
|
||||
$class = array_merge($class, $this->args);
|
||||
}
|
||||
Kiri::set($this->service, $class);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user