Skip to content

Commit c4a662a

Browse files
authored
PCBC-934: fix setting timeout for transaction (#113)
1 parent 3103b55 commit c4a662a

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

Couchbase/TransactionOptions.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class TransactionOptions
2626
{
2727
private ?string $durabilityLevel = null;
2828
private ?int $timeoutMilliseconds = null;
29+
private ?int $keyValueTimeoutMilliseconds = null;
2930

3031
/**
3132
* Specifies the timeout for the transaction.
@@ -41,6 +42,20 @@ public function timeout(int $milliseconds): TransactionOptions
4142
return $this;
4243
}
4344

45+
/**
46+
* Specifies the default timeout for KV operations, in milliseconds.
47+
*
48+
* @param int $milliseconds
49+
*
50+
* @return TransactionsOptins
51+
* @since 4.1.4
52+
*/
53+
public function keyValueTimeout(int $milliseconds): TransactionsOptions
54+
{
55+
$this->keyValueTimeoutMilliseconds = $milliseconds;
56+
return $this;
57+
}
58+
4459
/**
4560
* Specifies the level of synchronous durability level.
4661
*
@@ -75,6 +90,7 @@ public static function export(?TransactionOptions $options): array
7590
}
7691
return [
7792
'timeout' => $options->timeoutMilliseconds,
93+
'keyValueTimeout' => $options->keyValueTimeoutMilliseconds,
7894
'durabilityLevel' => $options->durabilityLevel,
7995
];
8096
}

package.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<email>sergey@couchbase.com</email>
1414
<active>yes</active>
1515
</lead>
16-
<date>2023-05-23</date>
16+
<date>2023-05-25</date>
1717
<version>
1818
<release>4.1.4</release>
1919
<api>4.0.0</api>
@@ -25,6 +25,7 @@
2525
<license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache V2</license>
2626
<notes>
2727
* Add `couchbase::` namespace to `durability_level`, fixes using Sync Durability. (#102)
28+
* PCBC-934: Fixed setting timeout for transaction.
2829

2930
Notable changes in core C++
3031
---------------------------

src/wrapper/transaction_context_resource.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ apply_options(transactions::transaction_options& config, zval* options)
800800

801801
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(options), key, value)
802802
{
803-
ASSIGN_DURATION_OPTION("timeout", config.kv_timeout, key, value);
803+
ASSIGN_DURATION_OPTION("timeout", config.expiration_time, key, value);
804+
ASSIGN_DURATION_OPTION("keyValueTimeout", config.kv_timeout, key, value);
804805
if (zend_binary_strcmp(ZSTR_VAL(key), ZSTR_LEN(key), ZEND_STRL("durabilityLevel")) == 0) {
805806
if (value == nullptr || Z_TYPE_P(value) == IS_NULL) {
806807
continue;

src/wrapper/transactions_resource.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ apply_options(couchbase::transactions::transactions_config& config, zval* option
153153

154154
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(options), key, value)
155155
{
156+
ASSIGN_DURATION_OPTION("timeout", config.expiration_time, key, value);
156157
ASSIGN_DURATION_OPTION("keyValueTimeout", config.kv_timeout, key, value);
157158
if (zend_binary_strcmp(ZSTR_VAL(key), ZSTR_LEN(key), ZEND_STRL("durabilityLevel")) == 0) {
158159
if (value == nullptr || Z_TYPE_P(value) == IS_NULL) {

0 commit comments

Comments
 (0)