File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed
Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 1111use DtmClient \Api \ApiInterface ;
1212use DtmClient \Api \HttpApi ;
1313use DtmClient \Api \HttpApiFactory ;
14+ use DtmClient \DBSpecial \DBSpecialFactory ;
1415use DtmClient \DBSpecial \DBSpecialInterface ;
15- use DtmClient \DBSpecial \MySqlDBSpecial ;
1616use DtmClient \DbTransaction \DBTransactionInterface ;
1717use DtmClient \DbTransaction \HyperfDbTransaction ;
1818use DtmClient \Grpc \GrpcClientManager ;
@@ -43,7 +43,7 @@ public function __invoke(): array
4343 ApiInterface::class => ApiFactory::class,
4444 GrpcClientManager::class => GrpcClientManagerFactory::class,
4545 DBTransactionInterface::class => HyperfDbTransaction::class,
46- DBSpecialInterface::class => MySqlDBSpecial ::class,
46+ DBSpecialInterface::class => DBSpecialFactory ::class,
4747 PathGeneratorInterface::class => DtmPatchGenerator::class,
4848 JsonRpcTransporter::class => JsonRpcPoolTransporter::class,
4949 ResponseInterface::class => Response::class,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+ /**
5+ * This file is part of DTM-PHP.
6+ *
7+ * @license https://github.com/dtm-php/dtm-client/blob/master/LICENSE
8+ */
9+ namespace DtmClient \DBSpecial ;
10+
11+ use DtmClient \Constants \DbType ;
12+ use DtmClient \Exception \UnsupportedException ;
13+ use Hyperf \Contract \ConfigInterface ;
14+ use Psr \Container \ContainerExceptionInterface ;
15+ use Psr \Container \ContainerInterface ;
16+ use Psr \Container \NotFoundExceptionInterface ;
17+
18+ class DBSpecialFactory
19+ {
20+ /**
21+ * @throws UnsupportedException
22+ * @throws NotFoundExceptionInterface
23+ * @throws ContainerExceptionInterface
24+ */
25+ public function __invoke (ContainerInterface $ container ): DBSpecialInterface
26+ {
27+ $ type = $ container ->get (ConfigInterface::class)->get ('dtm.barrier.db.type ' , DbType::MySQL);
28+ return match ($ type ) {
29+ DbType::MySQL => $ container ->get (MySqlDBSpecial::class),
30+ default => throw new UnsupportedException (),
31+ };
32+ }
33+ }
Original file line number Diff line number Diff line change 1717use DtmClient \Exception \InvalidArgumentException ;
1818use DtmClient \Exception \UnsupportedException ;
1919use DtmClient \Exception \XaTransactionException ;
20- use DtmClient \Grpc \Message \DtmBranchRequest ;
2120use Google \Protobuf \Internal \Message ;
2221
2322class XA extends AbstractTransaction
You can’t perform that action at this time.
0 commit comments