-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Transaction and request tagging support (#206)
- Loading branch information
1 parent
4caec32
commit 3f91d3b
Showing
7 changed files
with
152 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# v8.1.0 (2024-04-16) | ||
|
||
Added | ||
- Request and Transaction tagging support (#206) | ||
|
||
# v8.0.0 (2024-04-11) | ||
|
||
Added | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright 2019 Colopl Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Colopl\Spanner\Concerns; | ||
|
||
trait ManagesTagging | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
protected ?string $requestTag = null; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
protected ?string $transactionTag = null; | ||
|
||
/** | ||
* @param string|null $tag | ||
* @return $this | ||
*/ | ||
public function setRequestTag(?string $tag): static | ||
{ | ||
$this->requestTag = $tag; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getRequestTag(): ?string | ||
{ | ||
return $this->requestTag; | ||
} | ||
|
||
/** | ||
* @param string|null $tag | ||
* @return $this | ||
*/ | ||
public function setTransactionTag(?string $tag): static | ||
{ | ||
$this->transactionTag = $tag; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getTransactionTag(): ?string | ||
{ | ||
return $this->transactionTag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Copyright 2019 Colopl Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Colopl\Spanner\Tests\Concerns; | ||
|
||
use Colopl\Spanner\Connection; | ||
use Colopl\Spanner\Tests\TestCase; | ||
|
||
class ManagesTagsTest extends TestCase | ||
{ | ||
public function test_set_and_get_requestTag(): void | ||
{ | ||
$conn = $this->getConnection(); | ||
assert($conn instanceof Connection); | ||
$conn->setRequestTag('url=/api/users'); | ||
$this->assertSame('url=/api/users', $conn->getRequestTag()); | ||
$conn->setRequestTag(null); | ||
$this->assertNull($conn->getRequestTag()); | ||
} | ||
|
||
public function test_set_and_get_transactionTag(): void | ||
{ | ||
$conn = $this->getDefaultConnection(); | ||
assert($conn instanceof Connection); | ||
$conn->setTransactionTag('url=/api/users/update'); | ||
$this->assertSame('url=/api/users/update', $conn->getTransactionTag()); | ||
$conn->setTransactionTag(null); | ||
$this->assertNull($conn->getTransactionTag()); | ||
} | ||
} |