Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-20 19:04:16 +08:00
parent 862acf1db1
commit b557f15a98
7 changed files with 15 additions and 17 deletions
+4 -4
View File
@@ -219,20 +219,20 @@ abstract class BaseApplication extends Component
private function addEvent($key, $value): void private function addEvent($key, $value): void
{ {
if ($value instanceof \Closure || is_object($value)) { if ($value instanceof \Closure || is_object($value)) {
$this->eventProvider->on($key, $value, 0); $this->getEventProvider()->on($key, $value, 0);
return; return;
} }
if (is_array($value)) { if (is_array($value)) {
if (is_object($value[0]) && !($value[0] instanceof \Closure)) { if (is_object($value[0]) && !($value[0] instanceof \Closure)) {
$this->eventProvider->on($key, $value, 0); $this->getEventProvider()->on($key, $value, 0);
return; return;
} }
if (is_string($value[0])) { if (is_string($value[0])) {
$value[0] = Kiri::createObject($value[0]); $value[0] = Kiri::createObject($value[0]);
$this->eventProvider->on($key, $value, 0); $this->getEventProvider()->on($key, $value, 0);
return; return;
} }
@@ -241,7 +241,7 @@ abstract class BaseApplication extends Component
if (!is_callable($item, true)) { if (!is_callable($item, true)) {
throw new InitException("Class does not hav callback."); throw new InitException("Class does not hav callback.");
} }
$this->eventProvider->on($key, $item, 0); $this->getEventProvider()->on($key, $item, 0);
} }
} }
+1 -1
View File
@@ -239,7 +239,7 @@ class Application extends BaseApplication
scan_directory(MODEL_PATH, 'app\Model'); scan_directory(MODEL_PATH, 'app\Model');
} }
$this->container->setBindings(OutputInterface::class, $output); $this->getContainer()->setBindings(OutputInterface::class, $output);
$class->run($input, $output); $class->run($input, $output);
fire(new OnAfterCommandExecute()); fire(new OnAfterCommandExecute());
-7
View File
@@ -45,8 +45,6 @@ class Redis implements StopHeartbeatCheck
private int $_last = 0; private int $_last = 0;
private EventProvider $eventProvider;
/** /**
* @param array $config * @param array $config
@@ -67,9 +65,6 @@ class Redis implements StopHeartbeatCheck
public function init() public function init()
{ {
$this->heartbeat_check(); $this->heartbeat_check();
$this->eventProvider = Kiri::getDi()->get(EventProvider::class);
$this->eventProvider->on(OnWorkerExit::class, [$this, 'onWorkerExit']);
} }
@@ -110,8 +105,6 @@ class Redis implements StopHeartbeatCheck
if (time() - $this->_last > intval($this->pool['tick'] ?? 60)) { if (time() - $this->_last > intval($this->pool['tick'] ?? 60)) {
$this->stopHeartbeatCheck(); $this->stopHeartbeatCheck();
$this->eventProvider->off(OnWorkerExit::class, [$this, 'stopHeartbeatCheck']);
$this->pdo = null; $this->pdo = null;
} }
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
+6 -1
View File
@@ -19,6 +19,8 @@ use Kiri;
use Kiri\Pool\Redis as PoolRedis; use Kiri\Pool\Redis as PoolRedis;
use Kiri\Annotation\Inject; use Kiri\Annotation\Inject;
use Kiri\Server\Events\OnWorkerExit; use Kiri\Server\Events\OnWorkerExit;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Swoole\Timer; use Swoole\Timer;
/** /**
@@ -43,7 +45,10 @@ class Redis extends Component
/** /**
* @return void
* @throws ConfigException * @throws ConfigException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception * @throws Exception
*/ */
public function init() public function init()
@@ -54,7 +59,7 @@ class Redis extends Component
$length = Config::get('cache.redis.pool.max', 10); $length = Config::get('cache.redis.pool.max', 10);
$this->eventProvider->on(OnWorkerExit::class, [$this, 'destroy'], 0); $this->getEventProvider()->on(OnWorkerExit::class, [$this, 'destroy'], 0);
$connections->initConnections('Redis:' . $config['host'], true, $length); $connections->initConnections('Redis:' . $config['host'], true, $length);
} }
+1 -1
View File
@@ -37,7 +37,7 @@ class TaskManager extends Component
} }
$task_use_object = $swollen->setting['task_object'] ?? $swollen->setting['task_use_object'] ?? false; $task_use_object = $swollen->setting['task_object'] ?? $swollen->setting['task_use_object'] ?? false;
$reflect = $this->container->get(OnServerTask::class); $reflect = $this->getContainer()->get(OnServerTask::class);
$swollen->on('finish', [$reflect, 'onFinish']); $swollen->on('finish', [$reflect, 'onFinish']);
if ($task_use_object || $swollen->setting['task_enable_coroutine']) { if ($task_use_object || $swollen->setting['task_enable_coroutine']) {
+1 -1
View File
@@ -21,7 +21,7 @@ trait TaskResolve
if (!class_exists($handler) && $this->hashMap->has($handler)) { if (!class_exists($handler) && $this->hashMap->has($handler)) {
$handler = $this->hashMap->get($handler); $handler = $this->hashMap->get($handler);
} }
$implements = $this->container->getReflect($handler); $implements = $this->getContainer()->getReflect($handler);
if (!in_array(OnTaskInterface::class, $implements->getInterfaceNames())) { if (!in_array(OnTaskInterface::class, $implements->getInterfaceNames())) {
throw new Exception('Task must instance ' . OnTaskInterface::class); throw new Exception('Task must instance ' . OnTaskInterface::class);
} }
+2 -2
View File
@@ -41,14 +41,14 @@ class Server extends AbstractServer
*/ */
public function init() public function init()
{ {
$this->router = $this->container->get(DataGrip::class)->get('ws'); $this->router = $this->getContainer()->get(DataGrip::class)->get('ws');
$handler = $this->router->find('/', 'GET'); $handler = $this->router->find('/', 'GET');
if (is_int($handler) || is_null($handler)) { if (is_int($handler) || is_null($handler)) {
return; return;
} }
$this->callback = $handler->callback[0]; $this->callback = $handler->callback[0];
$this->sender = $this->container->get(Sender::class); $this->sender = $this->getContainer()->get(Sender::class);
$this->sender->setServer($this->server); $this->sender->setServer($this->server);
} }