modify plugin name
This commit is contained in:
+32
-3
@@ -3,12 +3,14 @@
|
||||
namespace Kiri\Rpc;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Context;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri;
|
||||
use Kiri\Abstracts\Component;
|
||||
use Kiri\Annotation\Inject;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri\Exception\ConfigException;
|
||||
use Kiri\Pool\Alias;
|
||||
use Kiri\Pool\Pool;
|
||||
use Kiri\Server\Events\OnBeforeShutdown;
|
||||
use Swoole\Client;
|
||||
|
||||
|
||||
@@ -32,6 +34,31 @@ class ClientPool extends Component
|
||||
public int $waite;
|
||||
|
||||
|
||||
#[Inject(EventProvider::class)]
|
||||
public EventProvider $provider;
|
||||
|
||||
|
||||
private array $names = [];
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->provider->on(OnBeforeShutdown::class, [$this, 'onBeforeShutdown']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onBeforeShutdown()
|
||||
{
|
||||
foreach ($this->names as $name) {
|
||||
$this->getPool()->clean($name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
* @param callable $callback
|
||||
@@ -45,6 +72,8 @@ class ClientPool extends Component
|
||||
|
||||
$pool = $config['pool'] ?? ['min' => 1, 'max' => 100];
|
||||
|
||||
$this->names[] = $coroutineName;
|
||||
|
||||
return $this->getPool()->get($coroutineName, $callback, $pool['min'] ?? 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user