static void setup(char **argv) { const char *endpoint; assert(session == NULL); assert(mock == NULL); assert(io == NULL); io = get_test_io_opts(); if (io == NULL) { err_exit("Failed to create IO session"); } mock = start_mock_server(argv); if (mock == NULL) { err_exit("Failed to start mock server"); } endpoint = get_mock_http_server(mock); session = libcouchbase_create(endpoint, "Administrator", "password", NULL, io); if (session == NULL) { err_exit("Failed to create libcouchbase session"); } (void)libcouchbase_set_error_callback(session, error_callback); if (libcouchbase_connect(session) != LIBCOUCHBASE_SUCCESS) { err_exit("Failed to connect to server"); } libcouchbase_wait(session); }
SV * PLCBA_construct(const char *pkg, AV *options) { PLCBA_t *async; char *host, *username, *password, *bucket; libcouchbase_t instance; SV *blessed_obj; Newxz(async, 1, PLCBA_t); extract_async_options(async, options); plcb_ctor_conversion_opts(&async->base, options); plcb_ctor_cbc_opts(options, &host, &username, &password, &bucket); instance = libcouchbase_create(host, username, password, bucket, plcba_make_io_opts(async)); if(!instance) { die("Couldn't create instance!"); } plcb_ctor_init_common(&async->base, instance, options); plcba_setup_callbacks(async); async->base_rv = newRV_inc(newSViv(PTR2IV(&(async->base)))); blessed_obj = newSV(0); sv_setiv(newSVrv(blessed_obj, pkg), PTR2IV(async)); return blessed_obj; }
static apr_status_t _couchbase_reslist_get_connection(void **conn_, void *params, apr_pool_t *pool) { mapcache_cache_couchbase *cache = (mapcache_cache_couchbase*)params; libcouchbase_t *instance = apr_pcalloc(pool,sizeof(libcouchbase_t)); const char *host = cache->host; const char *username = cache->username; const char *passwd = cache->password; const char *bucket = "default"; *instance = libcouchbase_create(host, username, passwd, bucket, NULL); if (*instance == NULL) { return APR_EGENERAL; } libcouchbase_set_error_callback(*instance, _couchbase_error_callback); libcouchbase_set_get_callback(*instance, _couchbase_get_callback); libcouchbase_set_storage_callback(*instance, _couchbase_store_callback); if (libcouchbase_connect(*instance) != LIBCOUCHBASE_SUCCESS) { return APR_EGENERAL; } /* Wait for the connect to compelete */ libcouchbase_wait(*instance); *conn_ = instance; return APR_SUCCESS; }
LIBCOUCHBASE_API libcouchbase_error_t libcouchbase_create_compat(libcouchbase_cluster_t type, const void *specific, libcouchbase_t *instance, struct libcouchbase_io_opt_st *io) { libcouchbase_error_t ret = LIBCOUCHBASE_NOT_SUPPORTED; VBUCKET_CONFIG_HANDLE config; *instance = libcouchbase_create(NULL, NULL, NULL, NULL, io); if (*instance == NULL) { return LIBCOUCHBASE_CLIENT_ENOMEM; } config = vbucket_config_create(); if (config == NULL) { libcouchbase_destroy(*instance); *instance = NULL; return LIBCOUCHBASE_CLIENT_ENOMEM; } if (type == LIBCOUCHBASE_MEMCACHED_CLUSTER) { ret = create_memcached(specific, config); } if (ret == LIBCOUCHBASE_SUCCESS) { libcouchbase_apply_vbucket_config(*instance, config); } else { vbucket_config_destroy(config); libcouchbase_destroy(*instance); *instance = NULL; } return ret; }