Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Middleware/DtmMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use DtmClient\Exception\OngingException;
use DtmClient\Exception\RuntimeException;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\Grpc\StatusCode;
use Hyperf\HttpMessage\Stream\SwooleStream;
Expand All @@ -33,11 +34,14 @@ class DtmMiddleware implements MiddlewareInterface

protected ConfigInterface $config;

public function __construct(Barrier $barrier, ResponseInterface $response, ConfigInterface $config)
protected StdoutLoggerInterface $logger;

public function __construct(Barrier $barrier, ResponseInterface $response, ConfigInterface $config, StdoutLoggerInterface $logger)
{
$this->barrier = $barrier;
$this->response = $response;
$this->config = $config;
$this->logger = $logger;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Expand Down Expand Up @@ -137,6 +141,7 @@ protected function handlerBarrierCall(callable $businessCall): ResponseInterface
$this->isGRPC() && $response = $response->withTrailer('grpc-status', (string) $failureException->getCode())->withTrailer('grpc-message', $failureException->getMessage());
return $response;
} catch (\Throwable $throwable) {
$this->logger->error((string)$throwable);
$code = $this->isGRPC() ? 200 : Result::FAILURE_STATUS;
$response = $response->withStatus($code);
$this->isGRPC() && $response = $response->withTrailer('grpc-status', (string) Result::FAILURE_STATUS)->withTrailer('grpc-message', $throwable->getMessage());
Expand Down
1 change: 1 addition & 0 deletions src/TCC.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function callBranch($body, string $tryUrl, string $confirmUrl, string $ca
$branchRequest->branchId = $branchId;
$branchRequest->op = Operation::TRY;
$branchRequest->body = $body;
$branchRequest->branchHeaders = TransContext::getBranchHeaders();
return $this->api->transRequestBranch($branchRequest);
case Protocol::GRPC:
if (! $body instanceof Message) {
Expand Down
Loading