|
1 | 1 | <?php |
2 | 2 |
|
3 | 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 | | - */ |
| 4 | + |
9 | 5 | namespace DtmClient; |
10 | 6 |
|
11 | 7 | use DtmClient\Api\ApiInterface; |
|
14 | 10 | use DtmClient\Constants\TransType; |
15 | 11 | use DtmClient\Exception\FailureException; |
16 | 12 | use DtmClient\Exception\UnsupportedException; |
| 13 | +use Exception; |
17 | 14 | use Google\Protobuf\GPBEmpty; |
18 | 15 | use Google\Protobuf\Internal\Message; |
19 | | -use GuzzleHttp\Psr7\Response; |
20 | 16 |
|
21 | 17 | class Msg extends AbstractTransaction |
22 | 18 | { |
@@ -70,20 +66,25 @@ public function submit() |
70 | 66 | return $this->api->submit(TransContext::toArray()); |
71 | 67 | } |
72 | 68 |
|
| 69 | + public function doAndSubmitDB(string $queryPrepared, callable $businessCall) |
| 70 | + { |
| 71 | + $this->doAndSubmit($queryPrepared, fn () => $this->barrier->call($businessCall)); |
| 72 | + } |
| 73 | + |
73 | 74 | public function doAndSubmit(string $queryPrepared, callable $businessCall) |
74 | 75 | { |
75 | 76 | $this->barrier->barrierFrom(TransType::MSG, TransContext::getGid(), '00', 'msg'); |
76 | 77 | $this->prepare($queryPrepared); |
77 | 78 | try { |
78 | | - $this->barrier->call($businessCall); |
| 79 | + $businessCall(); |
79 | 80 | $this->submit(); |
80 | 81 | } catch (FailureException $failureException) { |
81 | 82 | $this->api->abort([ |
82 | 83 | 'gid' => TransContext::getGid(), |
83 | 84 | 'trans_type' => TransType::MSG, |
84 | 85 | ]); |
85 | 86 | throw $failureException; |
86 | | - } catch (\Exception $exception) { |
| 87 | + } catch (Exception $exception) { |
87 | 88 | $this->queryPrepared($queryPrepared); |
88 | 89 | throw $exception; |
89 | 90 | } |
|
0 commit comments