Couchbase C Client  3.3.14
Asynchronous C Client for Couchbase
utils.h File Reference

Various utility functions. More...

Go to the source code of this file.

Macros

#define LCB_CONFIG_MCD_PORT
 
#define LCB_CONFIG_MCD_SSL_PORT
 
#define LCB_CONFIG_HTTP_PORT
 
#define LCB_CONFIG_HTTP_SSL_PORT
 
#define LCB_CONFIG_MCCOMPAT_PORT
 
#define LCB_CMD_SET_KEY(cmd, keybuf, keylen)
 Set the key for the command.
 
#define LCB_GETNODE_UNAVAILABLE
 String constant returned by lcb_get_node() when the LCB_NODE_NEVERNULL flag is specified, and no node can be returned.
 

Typedefs

typedef enum lcb_timeunit_t lcb_timeunit_t
 
typedef void(* lcb_timings_callback) (lcb_INSTANCE *instance, const void *cookie, lcb_timeunit_t timeunit, lcb_U32 min, lcb_U32 max, lcb_U32 total, lcb_U32 maxtotal)
 The following function is called for each bucket in the timings histogram when you call lcb_get_timings.
 
typedef struct lcb_histogram_st lcb_HISTOGRAM
 
typedef void(* lcb_HISTOGRAM_CALLBACK) (const void *cookie, lcb_timeunit_t timeunit, lcb_U32 min, lcb_U32 max, lcb_U32 total, lcb_U32 maxtotal)
 
typedef struct lcb_RESPGETMANIFEST_ lcb_RESPGETMANIFEST
 
typedef struct lcb_CMDGETMANIFEST_ lcb_CMDGETMANIFEST
 
typedef struct lcb_RESPGETCID_ lcb_RESPGETCID
 
typedef struct lcb_CMDGETCID_ lcb_CMDGETCID
 

Enumerations

enum  lcb_timeunit_t
 Time units reported by lcb_get_timings() More...
 
enum  lcb_DUMPFLAGS
 
enum  lcb_GETNODETYPE
 Type of node to retrieve for the lcb_get_node() function. More...
 

Functions

lcb_STATUS lcb_cbflush3 (lcb_INSTANCE *instance, void *cookie, const lcb_CMDCBFLUSH *cmd)
 
lcb_STATUS lcb_enable_timings (lcb_INSTANCE *instance)
 Start recording timing metrics for the different operations.
 
lcb_STATUS lcb_disable_timings (lcb_INSTANCE *instance)
 Stop recording (and release all resources from previous measurements) timing metrics.
 
lcb_STATUS lcb_get_timings (lcb_INSTANCE *instance, const void *cookie, lcb_timings_callback callback)
 Get the timings histogram.
 
void lcb_dump (lcb_INSTANCE *instance, FILE *fp, lcb_U32 flags)
 Write a textual dump to a file.
 
lcb_HISTOGRAM * lcb_histogram_create (void)
 
void lcb_histogram_destroy (lcb_HISTOGRAM *hg)
 
void lcb_histogram_record (lcb_HISTOGRAM *hg, lcb_U64 duration)
 
void lcb_histogram_read (const lcb_HISTOGRAM *hg, const void *cookie, lcb_HISTOGRAM_CALLBACK cb)
 
void lcb_histogram_print (lcb_HISTOGRAM *hg, FILE *stream)
 Print the histogram to the specified FILE.
 
lcb_STATUS lcb_respgetmanifest_status (const lcb_RESPGETMANIFEST *resp)
 
lcb_STATUS lcb_respgetmanifest_cookie (const lcb_RESPGETMANIFEST *resp, void **cookie)
 
lcb_STATUS lcb_respgetmanifest_value (const lcb_RESPGETMANIFEST *resp, const char **json, size_t *json_len)
 
lcb_STATUS lcb_cmdgetmanifest_create (lcb_CMDGETMANIFEST **cmd)
 
lcb_STATUS lcb_cmdgetmanifest_destroy (lcb_CMDGETMANIFEST *cmd)
 
lcb_STATUS lcb_cmdgetmanifest_timeout (lcb_CMDGETMANIFEST *cmd, uint32_t timeout)
 
lcb_STATUS lcb_getmanifest (lcb_INSTANCE *instance, void *cookie, const lcb_CMDGETMANIFEST *cmd)
 
lcb_STATUS lcb_respgetcid_status (const lcb_RESPGETCID *resp)
 
lcb_STATUS lcb_respgetcid_cookie (const lcb_RESPGETCID *resp, void **cookie)
 
lcb_STATUS lcb_respgetcid_manifest_id (const lcb_RESPGETCID *resp, uint64_t *id)
 
lcb_STATUS lcb_respgetcid_collection_id (const lcb_RESPGETCID *resp, uint32_t *id)
 
lcb_STATUS lcb_respgetcid_scoped_collection (const lcb_RESPGETCID *resp, const char **name, size_t *name_len)
 
lcb_STATUS lcb_cmdgetcid_create (lcb_CMDGETCID **cmd)
 
lcb_STATUS lcb_cmdgetcid_destroy (lcb_CMDGETCID *cmd)
 
lcb_STATUS lcb_cmdgetcid_scope (lcb_CMDGETCID *cmd, const char *scope, size_t scope_len)
 
lcb_STATUS lcb_cmdgetcid_collection (lcb_CMDGETCID *cmd, const char *collection, size_t collection_len)
 
lcb_STATUS lcb_cmdgetcid_timeout (lcb_CMDGETCID *cmd, uint32_t timeout)
 
lcb_STATUS lcb_getcid (lcb_INSTANCE *instance, void *cookie, const lcb_CMDGETCID *cmd)
 
const char * lcb_get_node (lcb_INSTANCE *instance, lcb_GETNODETYPE type, unsigned index)
 Return a string of host:port for a node of the given type.
 
const char * lcb_get_keynode (lcb_INSTANCE *instance, const void *key, size_t nkey)
 Get the target server for a given key.
 
lcb_S32 lcb_get_num_replicas (lcb_INSTANCE *instance)
 Get the number of the replicas in the cluster.
 
lcb_S32 lcb_get_num_nodes (lcb_INSTANCE *instance)
 Get the number of the nodes in the cluster.
 
const char *const * lcb_get_server_list (lcb_INSTANCE *instance)
 Get a list of nodes in the cluster.
 
void * lcb_mem_alloc (lcb_SIZE size)
 Functions to allocate and free memory related to libcouchbase.
 
void lcb_mem_free (void *ptr)
 Use this to free memory allocated with lcb_mem_alloc.
 
LCB_INTERNAL_API void lcb_run_loop (lcb_INSTANCE *instance)
 
LCB_INTERNAL_API void lcb_stop_loop (lcb_INSTANCE *instance)
 
LCB_INTERNAL_API lcb_U64 lcb_nstime (void)
 

Detailed Description

Various utility functions.

Stability
Uncommitted

Macro Definition Documentation

◆ LCB_CMD_SET_KEY

#define LCB_CMD_SET_KEY ( cmd,
keybuf,
keylen )

Set the key for the command.

Parameters
cmdA command derived from lcb_CMDBASE
keybufthe buffer for the key
keylenthe length of the key.
lcb_CMDGET cmd = { 0 };
LCB_CMD_SET_KEY(&cmd, "key", strlen("key"));
#define LCB_CMD_SET_KEY(cmd, keybuf, keylen)
Set the key for the command.
Definition utils.h:52

The storage for keybuf may be released or modified after the command has been spooled.

Examples
example/crypto/openssl_symmetric_decrypt.c, and example/crypto/openssl_symmetric_encrypt.c.

Enumeration Type Documentation

◆ lcb_DUMPFLAGS

Enumerator
LCB_DUMP_VBCONFIG 

Dump the raw vbucket configuration.

LCB_DUMP_PKTINFO 

Dump information about each packet.

LCB_DUMP_BUFINFO 

Dump memory usage/reservation information about buffers.

LCB_DUMP_METRICS 

Dump various metrics information.

LCB_DUMP_ALL 

Dump everything.

Function Documentation

◆ lcb_dump()

void lcb_dump ( lcb_INSTANCE * instance,
FILE * fp,
lcb_U32 flags )

Write a textual dump to a file.

Stability
Volatile

This function will inspect the various internal structures of the current client handle (indicated by instance) and write the state information to the file indicated by fp.

Parameters
instancethe handle to dump
fpthe file to which the dump should be written
flagsa set of modifiers (of lcb_DUMPFLAGS) indicating what information to dump. Note that a standard set of information is always dumped, but by default more verbose information is hidden, and may be enabled with these flags.

◆ lcb_histogram_create()

lcb_HISTOGRAM * lcb_histogram_create ( void )
Stability
Volatile
Create a histogram structure
Returns
a new histogram structure

◆ lcb_histogram_destroy()

void lcb_histogram_destroy ( lcb_HISTOGRAM * hg)
Stability
Volatile
free a histogram structure
Parameters
hgthe histogram

◆ lcb_histogram_record()

void lcb_histogram_record ( lcb_HISTOGRAM * hg,
lcb_U64 duration )
Stability
Volatile
Add an entry to a histogram structure
Parameters
hgthe histogram
durationthe duration in nanoseconds

◆ lcb_histogram_read()

void lcb_histogram_read ( const lcb_HISTOGRAM * hg,
const void * cookie,
lcb_HISTOGRAM_CALLBACK cb )
Stability
Volatile
Repeatedly invoke a callback for all entries in the histogram
Parameters
hgthe histogram
cookiepointer passed to callback
cbcallback to invoke

◆ lcb_histogram_print()

void lcb_histogram_print ( lcb_HISTOGRAM * hg,
FILE * stream )

Print the histogram to the specified FILE.

This essentially outputs the same raw information as lcb_histogram_read(), except it prints in implementation-defined format. It's simpler to use than lcb_histogram_read, but less flexible.

Parameters
hgthe histogram
streamFile to print the histogram to.

◆ lcb_mem_alloc()

void * lcb_mem_alloc ( lcb_SIZE size)

Functions to allocate and free memory related to libcouchbase.

This is mainly for use on Windows where it is possible that the DLL and EXE are using two different CRTs

◆ lcb_run_loop()

LCB_INTERNAL_API void lcb_run_loop ( lcb_INSTANCE * instance)
Stability
Internal

These two functions unconditionally start and stop the event loop. These should be used only when necessary. Use lcb_wait and lcb_breakout for safer variants.

Internally these proxy to the run_event_loop/stop_event_loop calls

◆ lcb_stop_loop()

LCB_INTERNAL_API void lcb_stop_loop ( lcb_INSTANCE * instance)
Stability
Internal

◆ lcb_nstime()

LCB_INTERNAL_API lcb_U64 lcb_nstime ( void )
Stability
Internal