Skip to content

Commit 5060b3e

Browse files
avsejMatt-Woz
andauthored
PCBC-1035: Lazy connections with options (#235)
* Update core for lazy connections * Expose lazy connections switch in ClusterOptions --------- Co-authored-by: Mateusz <[email protected]>
1 parent 9de1076 commit 5060b3e

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

Couchbase/ClusterOptions.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class ClusterOptions
5454
private ?bool $enableTracing = null;
5555
private ?bool $enableUnorderedExecution = null;
5656
private ?bool $showQueries = null;
57+
private ?bool $enableLazyConnections = null;
5758

5859
private ?string $network = null;
5960
private ?string $trustCertificate = null;
@@ -546,6 +547,20 @@ public function getTransactionsConfiguration(): ?TransactionsConfiguration
546547
return $this->transactionsConfiguration;
547548
}
548549

550+
/**
551+
* @param bool $enable
552+
*
553+
* @return ClusterOptions
554+
* @since 4.5.0
555+
*
556+
* @VOLATILE: This API is subject to change at any time.
557+
*/
558+
public function enableLazyConnections(bool $enable): ClusterOptions
559+
{
560+
$this->enableLazyConnections = $enable;
561+
return $this;
562+
}
563+
549564
/**
550565
* @return string the string that uniquely identifies particular authenticator layout
551566
* @throws InvalidArgumentException
@@ -610,6 +625,7 @@ public function export(): array
610625
'enableUnorderedExecution' => $this->enableUnorderedExecution,
611626
'useIpProtocol' => $this->useIpProtocol,
612627
'showQueries' => $this->showQueries,
628+
'enableLazyConnections' => $this->enableLazyConnections,
613629

614630
'network' => $this->network,
615631
'trustCertificate' => $this->trustCertificate,

bin/package.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def which(name, extra_locations = [])
5959
cmake_flags = [
6060
"-S#{cxx_core_source_dir}",
6161
"-B#{cxx_core_build_dir}",
62+
"-DCOUCHBASE_CXX_CLIENT_BUILD_OPENTELEMETRY=OFF",
6263
"-DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF",
6364
"-DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=OFF",
6465
"-DCOUCHBASE_CXX_CLIENT_BUILD_DOCS=OFF",
@@ -170,6 +171,7 @@ def which(name, extra_locations = [])
170171
cmake_flags = [
171172
"-S#{cxx_core_source_dir}",
172173
"-B#{cxx_core_build_dir}",
174+
"-DCOUCHBASE_CXX_CLIENT_BUILD_OPENTELEMETRY=OFF",
173175
"-DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF",
174176
"-DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=OFF",
175177
"-DCOUCHBASE_CXX_CLIENT_BUILD_DOCS=OFF",

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ string(
2121
set(COUCHBASE_CXX_CLIENT_WRAPPER_UNIFIED_ID
2222
"php/${CMAKE_MATCH_1}"
2323
CACHE STRING "" FORCE)
24+
set(COUCHBASE_CXX_CLIENT_BUILD_OPENTELEMETRY
25+
OFF
26+
CACHE BOOL "" FORCE)
2427
set(COUCHBASE_CXX_CLIENT_BUILD_DOCS
2528
OFF
2629
CACHE BOOL "" FORCE)

src/deps/couchbase-cxx-client

src/wrapper/connection_handle.cxx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
#include "passthrough_transcoder.hxx"
2626
#include "version.hxx"
2727

28+
#define COUCHBASE_CXX_CLIENT_IGNORE_CORE_DEPRECATIONS
2829
#include <core/cluster.hxx>
2930
#include <core/error_context/analytics.hxx>
3031
#include <core/error_context/search.hxx>
3132
#include <core/error_context/view.hxx>
3233
#include <core/logger/logger.hxx>
3334
#include <core/management/bucket_settings.hxx>
3435
#include <core/operations.hxx>
36+
#include <core/operations/document_view.hxx>
3537
#include <core/operations/management/analytics.hxx>
3638
#include <core/operations/management/bucket.hxx>
3739
#include <core/operations/management/cluster_describe.hxx>
@@ -3630,9 +3632,7 @@ zval_to_bucket_settings(const zval* bucket_settings)
36303632
return { e, {} };
36313633
}
36323634

3633-
if (auto e = cb_assign_integer(
3634-
bucket.num_vbuckets, bucket_settings, "numVBuckets");
3635-
e.ec) {
3635+
if (auto e = cb_assign_integer(bucket.num_vbuckets, bucket_settings, "numVBuckets"); e.ec) {
36363636
return { e, {} };
36373637
}
36383638

@@ -3828,8 +3828,7 @@ cb_bucket_settings_to_zval(
38283828
}
38293829

38303830
if (bucket_settings.num_vbuckets.has_value()) {
3831-
add_assoc_long(
3832-
return_value, "numVBuckets", bucket_settings.num_vbuckets.value());
3831+
add_assoc_long(return_value, "numVBuckets", bucket_settings.num_vbuckets.value());
38333832
}
38343833

38353834
return {};
@@ -6067,6 +6066,9 @@ apply_options(couchbase::cluster_options& cluster_options, zval* options) -> cor
60676066
options::assign_boolean(ZEND_STRL("enableTcpKeepAlive"), key, value, [&](auto v) {
60686067
cluster_options.network().enable_tcp_keep_alive(v);
60696068
});
6069+
options::assign_boolean(ZEND_STRL("enableLazyConnections"), key, value, [&](auto v) {
6070+
cluster_options.network().enable_lazy_connections(v);
6071+
});
60706072
options::assign_boolean(ZEND_STRL("enableUnorderedExecution"), key, value, [&](auto v) {
60716073
cluster_options.behavior().enable_unordered_execution(v);
60726074
});
@@ -6223,7 +6225,8 @@ apply_options(couchbase::cluster_options& cluster_options, zval* options) -> cor
62236225
ZEND_HASH_FOREACH_END();
62246226
}
62256227

6226-
if (zend_binary_strcmp(ZSTR_VAL(key), ZSTR_LEN(key), ZEND_STRL("appTelemetryConfiguration")) == 0) {
6228+
if (zend_binary_strcmp(
6229+
ZSTR_VAL(key), ZSTR_LEN(key), ZEND_STRL("appTelemetryConfiguration")) == 0) {
62276230
if (value == nullptr || Z_TYPE_P(value) == IS_NULL) {
62286231
continue;
62296232
}

0 commit comments

Comments
 (0)