Compare commits

...

1 Commits

Author SHA1 Message Date
as2252258 7eb6151111 改名 2021-12-08 11:32:31 +08:00
2 changed files with 6 additions and 20 deletions
+6 -12
View File
@@ -75,24 +75,18 @@ class Connection extends Component
public Schema $_schema; public Schema $_schema;
/**
* @var EventProvider
*/
#[Inject(EventProvider::class)]
public EventProvider $eventProvider;
/** /**
* execute by __construct * execute by __construct
* @throws Exception * @throws Exception
*/ */
public function init() public function init()
{ {
$this->eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0); $eventProvider = Kiri::getDi()->get(EventProvider::class);
$this->eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0); $eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
$this->eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0); $eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
$this->eventProvider->on(Rollback::class, [$this, 'rollback'], 0); $eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
$this->eventProvider->on(Commit::class, [$this, 'commit'], 0); $eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
$eventProvider->on(Commit::class, [$this, 'commit'], 0);
if (Db::transactionsActive()) { if (Db::transactionsActive()) {
$this->beginTransaction(); $this->beginTransaction();
-8
View File
@@ -11,7 +11,6 @@ use Kiri\Application;
use Kiri\Events\EventProvider; use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
use Kiri\Kiri; use Kiri\Kiri;
use Note\Inject;
use Server\Events\OnWorkerStart; use Server\Events\OnWorkerStart;
/** /**
@@ -24,13 +23,6 @@ class DatabasesProviders extends Providers
private array $_pooLength = ['min' => 0, 'max' => 1]; private array $_pooLength = ['min' => 0, 'max' => 1];
/**
* @var EventProvider
*/
#[Inject(EventProvider::class)]
public EventProvider $eventProvider;
/** /**
* @param Application $application * @param Application $application
* @throws Exception * @throws Exception