int main(int argc, char **argv) { lcb_t instance; struct lcb_create_st cropts; lcb_error_t rc; memset(&cropts, 0, sizeof cropts); cropts.version = 3; cropts.v.v3.connstr = "couchbases://10.0.0.31/default?certpath=/tmp/couchbase-ssl-certificate.pem"; rc = lcb_create(&instance, &cropts); if (rc != LCB_SUCCESS) { die(rc, "Creating instance"); } rc = lcb_connect(instance); if (rc != LCB_SUCCESS) { die(rc, "Connection scheduling"); } /* This function required to actually schedule the operations on the network */ lcb_wait(instance); /* Determines if the bootstrap/connection succeeded */ rc = lcb_get_bootstrap_status(instance); if (rc != LCB_SUCCESS) { die(rc, "Connection bootstraping"); } else { printf("Connection succeeded. Cluster has %d nodes\n", lcb_get_num_nodes(instance)); } /* SSL connections use different ports. For example, the REST API * connection will use port 18091 rather than 8091 when using SSL */ const char *node = lcb_get_node(instance, LCB_NODE_HTCONFIG, 0); printf("First node address for REST API: %s\n", node); lcb_destroy(instance); return 0; }
PHP_COUCHBASE_LOCAL int validate_simple_observe_clause(lcb_t instance, int persist, int replicas TSRMLS_DC) { int num_replicas = lcb_get_num_replicas(instance); int num_nodes = lcb_get_num_nodes(instance); if ((persist > (num_replicas + 1)) || (replicas > num_replicas)) { zend_throw_exception(cb_not_enough_nodes_exception, "Not enough replicas to fulfill the request", 0 TSRMLS_CC); return -1; } if ((persist > num_nodes) || ((replicas + 1) > num_nodes)) { zend_throw_exception(cb_not_enough_nodes_exception, "Not enough nodes to fulfill the request", 0 TSRMLS_CC); return -1; } return 0; }