2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * @brief Couchbase wrapper function prototypes and datatypes.
23 * @copyright 2013-2014 Aaron Hurt <ahurt@anbcs.com>
29 RCSIDH(couchbase_h, "$Id$");
31 #include <libcouchbase/couchbase.h>
32 #include <json/json.h>
34 /* struct to hold cookie data for couchbase callbacks */
35 typedef struct cookie_t {
36 json_object *jobj; /* json object */
37 json_tokener *jtok; /* json tokener */
38 enum json_tokener_error jerr; /* tokener error */
41 /* union of const and non const pointers */
42 typedef union cookie_u {
47 /* general error callback */
48 void couchbase_error_callback(lcb_t instance, lcb_error_t error, const char *errinfo);
50 /* store a key/document in couchbase */
51 void couchbase_store_callback(lcb_t instance, const void *cookie, lcb_storage_t operation,
52 lcb_error_t error, const lcb_store_resp_t *item);
54 /* get a document by key from couchbase */
55 void couchbase_get_callback(lcb_t instance, const void *cookie, lcb_error_t error,
56 const lcb_get_resp_t *item);
58 /* create a couchbase instance and connect to the cluster */
59 lcb_t couchbase_init_connection(const char *host, const char *bucket, const char *pass);
61 /* store document/key in couchbase */
62 lcb_error_t couchbase_set_key(lcb_t instance, const char *key, const char *document, int expire);
64 /* pull document from couchbase by key */
65 lcb_error_t couchbase_get_key(lcb_t instance, const void *cookie, const char *key);
67 #endif /* _couchbase_h_ */