Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Commit d05264f

Browse files
committed
PCBC-246 Add support for LCB_CNTL_SKIP_CONFIGURATION_ERRORS_ON_CONNECT
Change-Id: Ib3a165a9d8d5eadc951771e0cf6fbfa66969c251 Reviewed-on: http://review.couchbase.org/28566 Reviewed-by: Trond Norbye <trond.norbye@gmail.com> Tested-by: Trond Norbye <trond.norbye@gmail.com>
1 parent e0aa8ff commit d05264f

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

apidecl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,14 @@ STD_PHP_INI_BOOLEAN(PCBC_INIENT_INST_RESTFLUSH,
12411241
zend_couchbase_globals,
12421242
couchbase_globals)
12431243

1244+
STD_PHP_INI_BOOLEAN(PCBC_INIENT_INST_SKIP_CONFIG_ERROR_ON_CONNECT,
1245+
PCBC_INIDEFL_INST_SKIP_CONFIG_ERROR_ON_CONNECT,
1246+
PHP_INI_ALL,
1247+
OnUpdateBool,
1248+
skip_config_errors_on_connect,
1249+
zend_couchbase_globals,
1250+
couchbase_globals)
1251+
12441252
PHP_INI_END()
12451253

12461254

create.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,19 @@ void php_couchbase_create_impl(INTERNAL_FUNCTION_PARAMETERS, int oo)
366366
"Failed to create libcouchbase instance");
367367
return;
368368
}
369+
370+
if (COUCHBASE_G(skip_config_errors_on_connect)) {
371+
int enable = 1;
372+
if (lcb_cntl(handle, LCB_CNTL_SET,
373+
LCB_CNTL_SKIP_CONFIGURATION_ERRORS_ON_CONNECT,
374+
&enable) != LCB_SUCCESS) {
375+
free_connparams(&cparams);
376+
lcb_destroy(handle);
377+
couchbase_report_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, oo,
378+
cb_lcb_exception,
379+
"Failed to enable skip_config_errors_on_connect");
380+
}
381+
}
369382
} else {
370383
lcb_error_t err;
371384
char cachefile[1024];

example/couchbase.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,14 @@ couchbase.restflush = On
9797
; containing the cluster topology (used to cache the configuration
9898
; instead of connecting to the rest server each time to download it)
9999
couchbase.config_cache = ""
100+
101+
; Try to connect to the next node in the configuration list if
102+
; the node don't contain the name of the bucket, or the
103+
; credentials is incorrect. This situation may occur if
104+
; the node is removed from the cluster, but is still listening
105+
; on the port.
106+
;
107+
; The parameter may be set to:
108+
; On = Try next node if bucket doesn't exist (or with incorrect cred)
109+
; Off = Fail if the bucket doesn't exist or the credentials is incorrect
110+
couchbase.skip_config_errors_on_connect = Off

internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ typedef struct _php_couchbase_ctx {
174174
ZEND_BEGIN_MODULE_GLOBALS(couchbase)
175175
zend_bool persistent;
176176
zend_bool restflush;
177+
zend_bool skip_config_errors_on_connect;
177178
char serializer_real;
178179
char *serializer;
179180
char compressor_real;
@@ -320,6 +321,9 @@ PHP_FUNCTION(couchbase_list_design_docs);
320321
#define PCBC_INIENT_CONFIG_CACHE "couchbase.config_cache"
321322
#define PCBC_INIDEFL_CONFIG_CACHE ""
322323

324+
#define PCBC_INIENT_INST_SKIP_CONFIG_ERROR_ON_CONNECT "couchbase.skip_config_errors_on_connect"
325+
#define PCBC_INIDEFL_INST_SKIP_CONFIG_ERROR_ON_CONNECT "Off"
326+
323327
/**
324328
* Hash table manipulation functions.
325329
*/

0 commit comments

Comments
 (0)