Skip to content

Commit

Permalink
Upgrade hyperf version to 3.0 (#5)
Browse files Browse the repository at this point in the history
Fixed bug
  • Loading branch information
PandaLIU-1111 authored Jul 28, 2022
1 parent 08db0e6 commit 54e1a9c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"php": ">=8.0",
"antlr/antlr4-php-runtime": "^0.5.1",
"greenlion/php-sql-parser": "^4.4",
"hyperf/context": "v3.0.x-dev",
"hyperf/engine-swow": "^2.0",
"hyperf/utils": "*"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Annotation/GlobalTransactionScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class GlobalTransactionScanner
public function __construct(ConfigInterface $config, LoggerFactory $loggerFactory, RMClient $RMClient, TMClient $TMClient)
{
$this->config = $config;
$this->applicationId = $this->config->get('seata.application_id');
$this->txServiceGroup = $this->config->get('seata.tx_service_group');
$this->applicationId = (string) $this->config->get('seata.application_id');
$this->txServiceGroup = (string) $this->config->get('seata.tx_service_group');
// @TODO mode
$this->mode = $this->config->get('seata.mode', self::DEFAULT_MODE);
// @TODO disableGlobalTransaction
Expand Down
19 changes: 12 additions & 7 deletions src/Core/Rpc/Runtime/SocketManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
use Hyperf\Seata\Exception\RuntimeException;
use Hyperf\Seata\Logger\LoggerFactory;
use Hyperf\Seata\Logger\LoggerInterface;
use Hyperf\Utils\Engine;
use Hyperf\Context\Context;
use Swoole\Coroutine\Socket as SwooleSocket;
use Swow\Exception;
use Swow\Socket as SwowSocket;
use Hyperf\Engine\Constant as EngineConstant;

class SocketManager
{
const SWOW = 'Swow';

const SWOOLE = 'Swoole';

protected RegistryFactory $registryFactory;

protected LoggerInterface $logger;
Expand All @@ -35,8 +40,8 @@ class SocketManager
protected array $processorTable = [];

protected array $adapters = [
Engine::ENGINE_SWOOLE => SwooleSocketChannel::class,
Engine::ENGINE_SWOW => SwowSocketChannel::class,
self::SWOW => SwooleSocketChannel::class,
self::SWOOLE => SwowSocketChannel::class,
];

public function __construct(RegistryFactory $registryFactory, LoggerFactory $loggerFactory)
Expand Down Expand Up @@ -86,9 +91,9 @@ public function getAvailServerList(string $transactionServiceGroup): array

protected function createSocket(Address $address): SwowSocket|SwooleSocket
{
if (Engine::isRunningInSwoole()) {
if (EngineConstant::ENGINE == self::SWOOLE) {
$socket = new SwooleSocket(AF_INET, SOCK_STREAM, 0);
} elseif (Engine::isRunningInSwow()) {
} elseif (EngineConstant::ENGINE == self::SWOW) {
$socket = new SwowSocket(SwowSocket::TYPE_TCP);
} else {
throw new RuntimeException('Invalid runtime engine');
Expand All @@ -100,10 +105,10 @@ protected function createSocket(Address $address): SwowSocket|SwooleSocket

protected function createSocketChannel(SwooleSocket|SwowSocket $socket, Address $address): SocketChannelInterface
{
if (Engine::isRunningInSwoole()) {
if (EngineConstant::ENGINE == self::SWOOLE) {
return new SwooleSocketChannel($socket, $address);
}
if (Engine::isRunningInSwow()) {
if (EngineConstant::ENGINE == self::SWOW) {
return new SwowSocketChannel($socket, $address);
}
throw new RuntimeException('Invalid runtime engine');
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/InitListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function listen(): array
];
}

public function process(object $event)
public function process(object $event): void
{
// Execute any sql to init the database connection
Db::select('select 1');
Expand Down

0 comments on commit 54e1a9c

Please sign in to comment.