couchbase 1.3.4-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +22 -0
  4. data/.yardopts +5 -0
  5. data/CONTRIBUTING.markdown +75 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +201 -0
  8. data/Makefile +3 -0
  9. data/README.markdown +649 -0
  10. data/RELEASE_NOTES.markdown +796 -0
  11. data/Rakefile +20 -0
  12. data/couchbase.gemspec +49 -0
  13. data/examples/chat-em/Gemfile +7 -0
  14. data/examples/chat-em/README.markdown +45 -0
  15. data/examples/chat-em/server.rb +82 -0
  16. data/examples/chat-goliath-grape/Gemfile +5 -0
  17. data/examples/chat-goliath-grape/README.markdown +50 -0
  18. data/examples/chat-goliath-grape/app.rb +67 -0
  19. data/examples/chat-goliath-grape/config/app.rb +20 -0
  20. data/examples/transcoders/Gemfile +3 -0
  21. data/examples/transcoders/README.markdown +59 -0
  22. data/examples/transcoders/cb-zcat +40 -0
  23. data/examples/transcoders/cb-zcp +45 -0
  24. data/examples/transcoders/gzip_transcoder.rb +49 -0
  25. data/examples/transcoders/options.rb +54 -0
  26. data/ext/couchbase_ext/.gitignore +4 -0
  27. data/ext/couchbase_ext/arguments.c +956 -0
  28. data/ext/couchbase_ext/arithmetic.c +307 -0
  29. data/ext/couchbase_ext/bucket.c +1370 -0
  30. data/ext/couchbase_ext/context.c +65 -0
  31. data/ext/couchbase_ext/couchbase_ext.c +1364 -0
  32. data/ext/couchbase_ext/couchbase_ext.h +644 -0
  33. data/ext/couchbase_ext/delete.c +163 -0
  34. data/ext/couchbase_ext/eventmachine_plugin.c +452 -0
  35. data/ext/couchbase_ext/extconf.rb +168 -0
  36. data/ext/couchbase_ext/get.c +316 -0
  37. data/ext/couchbase_ext/gethrtime.c +129 -0
  38. data/ext/couchbase_ext/http.c +432 -0
  39. data/ext/couchbase_ext/multithread_plugin.c +1090 -0
  40. data/ext/couchbase_ext/observe.c +171 -0
  41. data/ext/couchbase_ext/plugin_common.c +171 -0
  42. data/ext/couchbase_ext/result.c +129 -0
  43. data/ext/couchbase_ext/stats.c +163 -0
  44. data/ext/couchbase_ext/store.c +542 -0
  45. data/ext/couchbase_ext/timer.c +192 -0
  46. data/ext/couchbase_ext/touch.c +186 -0
  47. data/ext/couchbase_ext/unlock.c +176 -0
  48. data/ext/couchbase_ext/utils.c +551 -0
  49. data/ext/couchbase_ext/version.c +142 -0
  50. data/lib/action_dispatch/middleware/session/couchbase_store.rb +38 -0
  51. data/lib/active_support/cache/couchbase_store.rb +430 -0
  52. data/lib/couchbase.rb +155 -0
  53. data/lib/couchbase/bucket.rb +457 -0
  54. data/lib/couchbase/cluster.rb +119 -0
  55. data/lib/couchbase/connection_pool.rb +58 -0
  56. data/lib/couchbase/constants.rb +12 -0
  57. data/lib/couchbase/result.rb +26 -0
  58. data/lib/couchbase/transcoder.rb +120 -0
  59. data/lib/couchbase/utils.rb +62 -0
  60. data/lib/couchbase/version.rb +21 -0
  61. data/lib/couchbase/view.rb +506 -0
  62. data/lib/couchbase/view_row.rb +272 -0
  63. data/lib/ext/multi_json_fix.rb +56 -0
  64. data/lib/rack/session/couchbase.rb +108 -0
  65. data/tasks/benchmark.rake +6 -0
  66. data/tasks/compile.rake +158 -0
  67. data/tasks/test.rake +100 -0
  68. data/tasks/util.rake +21 -0
  69. data/test/profile/.gitignore +1 -0
  70. data/test/profile/Gemfile +6 -0
  71. data/test/profile/benchmark.rb +195 -0
  72. data/test/setup.rb +178 -0
  73. data/test/test_arithmetic.rb +185 -0
  74. data/test/test_async.rb +316 -0
  75. data/test/test_bucket.rb +250 -0
  76. data/test/test_cas.rb +235 -0
  77. data/test/test_couchbase.rb +77 -0
  78. data/test/test_couchbase_connection_pool.rb +77 -0
  79. data/test/test_couchbase_rails_cache_store.rb +361 -0
  80. data/test/test_delete.rb +120 -0
  81. data/test/test_errors.rb +82 -0
  82. data/test/test_eventmachine.rb +70 -0
  83. data/test/test_format.rb +164 -0
  84. data/test/test_get.rb +407 -0
  85. data/test/test_stats.rb +57 -0
  86. data/test/test_store.rb +216 -0
  87. data/test/test_timer.rb +42 -0
  88. data/test/test_touch.rb +97 -0
  89. data/test/test_unlock.rb +119 -0
  90. data/test/test_utils.rb +58 -0
  91. data/test/test_version.rb +52 -0
  92. metadata +336 -0
@@ -0,0 +1,644 @@
1
+ /* vim: ft=c et ts=8 sts=4 sw=4 cino=
2
+ *
3
+ * Copyright 2011, 2012 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ #ifndef COUCHBASE_EXT_H
18
+ #define COUCHBASE_EXT_H
19
+
20
+ #include <ruby.h>
21
+ #ifndef RUBY_ST_H
22
+ #include <st.h>
23
+ #endif
24
+
25
+ #ifdef HAVE_RUBY_THREAD_H
26
+ #include <ruby/thread.h>
27
+ #endif
28
+
29
+ #include "couchbase_config.h"
30
+ #ifdef HAVE_RB_FIBER_YIELD
31
+ #define BUILD_EVENTMACHINE_PLUGIN
32
+ #endif
33
+ #ifdef HAVE_STDINT_H
34
+ #include <stdint.h>
35
+ #endif
36
+ #ifndef HAVE_GETHRTIME
37
+ typedef uint64_t hrtime_t;
38
+ extern hrtime_t gethrtime(void);
39
+ #endif
40
+
41
+ #include <stdint.h>
42
+ #include <libcouchbase/couchbase.h>
43
+
44
+ #ifdef HAVE_RUBY_ENCODING_H
45
+ #include "ruby/encoding.h"
46
+ #define STR_NEW(ptr, len) rb_external_str_new((ptr), (len))
47
+ #define STR_NEW_CSTR(str) rb_external_str_new_cstr((str))
48
+ #else
49
+ #define STR_NEW(ptr, len) rb_str_new((ptr), (len))
50
+ #define STR_NEW_CSTR(str) rb_str_new2((str))
51
+ #endif
52
+
53
+ #ifdef HAVE_STDARG_PROTOTYPES
54
+ #include <stdarg.h>
55
+ #define va_init_list(a,b) va_start(a,b)
56
+ #else
57
+ #include <varargs.h>
58
+ #define va_init_list(a,b) va_start(a)
59
+ #endif
60
+
61
+ #ifndef HAVE_RB_HASH_LOOKUP2
62
+ VALUE rb_hash_lookup2(VALUE, VALUE, VALUE);
63
+ #endif
64
+ #ifndef HAVE_TYPE_ST_INDEX_T
65
+ typedef st_data_t st_index_t;
66
+ #endif
67
+
68
+ #define cb_debug_object(OBJ) do { \
69
+ VALUE debug_args[6] = { \
70
+ rb_funcall(OBJ, rb_intern("object_id"), 0), \
71
+ STR_NEW_CSTR(" "), \
72
+ rb_funcall(OBJ, rb_intern("class"), 0), \
73
+ STR_NEW_CSTR(" "), \
74
+ rb_funcall(OBJ, rb_intern("inspect"), 0), \
75
+ STR_NEW_CSTR("\n") }; \
76
+ rb_funcall2(rb_stderr, rb_intern("print"), 6, debug_args); \
77
+ } while(0)
78
+
79
+ #define CB_FMT_MASK 0x3
80
+ #define CB_FMT_DOCUMENT 0x0
81
+ #define CB_FMT_MARSHAL 0x1
82
+ #define CB_FMT_PLAIN 0x2
83
+
84
+ #define CB_PACKET_HEADER_SIZE 24
85
+ /* Structs */
86
+ struct cb_bucket_st
87
+ {
88
+ lcb_t handle;
89
+ lcb_type_t type;
90
+ struct lcb_io_opt_st *io;
91
+ uint16_t port;
92
+ VALUE authority;
93
+ VALUE hostname;
94
+ VALUE pool;
95
+ VALUE bucket;
96
+ VALUE username;
97
+ VALUE password;
98
+ VALUE engine;
99
+ int async;
100
+ int quiet;
101
+ uint8_t connected; /* non-zero if instance has been connected. it is possible to defer connection with :async option */
102
+ uint8_t running; /* non-zero if event loop is running */
103
+ uint8_t trigger_connect_cb_on_set; /* if non-zero, the on_connect callback will be triggered immediately after set */
104
+ VALUE transcoder;
105
+ uint32_t default_flags;
106
+ time_t default_ttl;
107
+ time_t default_observe_timeout;
108
+ lcb_uint64_t default_arith_create; /* should the incr/decr create the key? if non-zero, will use arith_init */
109
+ lcb_uint64_t default_arith_init; /* default initial value for incr/decr */
110
+ uint32_t timeout;
111
+ size_t threshold; /* the number of bytes to trigger event loop, zero if don't care */
112
+ size_t nbytes; /* the number of bytes scheduled to be sent */
113
+ VALUE exception; /* error delivered by error_callback */
114
+ VALUE on_error_proc; /* is using to deliver errors in async mode */
115
+ VALUE on_connect_proc; /* used to notify that instance ready to handle requests in async mode */
116
+ VALUE environment; /* sym_development or sym_production */
117
+ VALUE key_prefix_val;
118
+ VALUE node_list;
119
+ st_table *object_space;
120
+ char destroying;
121
+ char async_disconnect_hook_set;
122
+ VALUE self; /* the pointer to bucket representation in ruby land */
123
+ };
124
+
125
+ struct cb_http_request_st;
126
+ struct cb_context_st
127
+ {
128
+ struct cb_bucket_st* bucket;
129
+ int extended;
130
+ VALUE proc;
131
+ VALUE rv;
132
+ VALUE exception;
133
+ VALUE observe_options;
134
+ VALUE transcoder;
135
+ VALUE transcoder_opts;
136
+ VALUE operation;
137
+ VALUE headers_val;
138
+ int headers_built;
139
+ struct cb_http_request_st *request;
140
+ int quiet;
141
+ int arith; /* incr: +1, decr: -1, other: 0 */
142
+ int all_replicas; /* handle multiple responses from get_replica if non-zero */
143
+ size_t nqueries;
144
+ };
145
+
146
+ struct cb_http_request_st {
147
+ struct cb_bucket_st *bucket;
148
+ VALUE bucket_obj;
149
+ VALUE type;
150
+ int extended;
151
+ int running;
152
+ int completed;
153
+ lcb_http_request_t request;
154
+ lcb_http_cmd_t cmd;
155
+ struct cb_context_st *ctx;
156
+ VALUE on_body_callback;
157
+ };
158
+
159
+ struct cb_timer_st
160
+ {
161
+ struct cb_bucket_st *bucket;
162
+ int periodic;
163
+ uint32_t usec;
164
+ lcb_timer_t timer;
165
+ VALUE self;
166
+ VALUE callback;
167
+ };
168
+
169
+ /* Classes */
170
+ extern VALUE cb_cBucket;
171
+ extern VALUE cb_cCouchRequest;
172
+ extern VALUE cb_cResult;
173
+ extern VALUE cb_cTimer;
174
+
175
+ /* Modules */
176
+ extern VALUE cb_mCouchbase;
177
+ extern VALUE cb_mError;
178
+ extern VALUE cb_mTranscoder;
179
+ extern VALUE cb_mDocument;
180
+ extern VALUE cb_mPlain;
181
+ extern VALUE cb_mMarshal;
182
+ extern VALUE cb_mURI;
183
+ extern VALUE em_m;
184
+
185
+ /* Symbols */
186
+ extern ID cb_sym_add;
187
+ extern ID cb_sym_all;
188
+ extern ID cb_sym_append;
189
+ extern ID cb_sym_assemble_hash;
190
+ extern ID cb_sym_async;
191
+ extern ID cb_sym_body;
192
+ extern ID cb_sym_bucket;
193
+ extern ID cb_sym_cas;
194
+ extern ID cb_sym_chunked;
195
+ extern ID cb_sym_cluster;
196
+ extern ID cb_sym_connect;
197
+ extern ID cb_sym_content_type;
198
+ extern ID cb_sym_create;
199
+ extern ID cb_sym_decrement;
200
+ extern ID cb_sym_default;
201
+ extern ID cb_sym_default_arithmetic_init;
202
+ extern ID cb_sym_default_flags;
203
+ extern ID cb_sym_default_format;
204
+ extern ID cb_sym_default_observe_timeout;
205
+ extern ID cb_sym_default_ttl;
206
+ extern ID cb_sym_delete;
207
+ extern ID cb_sym_delta;
208
+ extern ID cb_sym_development;
209
+ extern ID cb_sym_document;
210
+ extern ID cb_sym_engine;
211
+ extern ID cb_sym_environment;
212
+ extern ID cb_sym_eventmachine;
213
+ extern ID cb_sym_extended;
214
+ extern ID cb_sym_first;
215
+ extern ID cb_sym_flags;
216
+ extern ID cb_sym_forced;
217
+ extern ID cb_sym_format;
218
+ extern ID cb_sym_found;
219
+ extern ID cb_sym_get;
220
+ extern ID cb_sym_hostname;
221
+ extern ID cb_sym_http_request;
222
+ extern ID cb_sym_increment;
223
+ extern ID cb_sym_initial;
224
+ extern ID cb_sym_iocp;
225
+ extern ID cb_sym_key_prefix;
226
+ extern ID cb_sym_libev;
227
+ extern ID cb_sym_libevent;
228
+ extern ID cb_sym_lock;
229
+ extern ID cb_sym_management;
230
+ extern ID cb_sym_marshal;
231
+ extern ID cb_sym_method;
232
+ extern ID cb_sym_node_list;
233
+ extern ID cb_sym_not_found;
234
+ extern ID cb_sym_num_replicas;
235
+ extern ID cb_sym_observe;
236
+ extern ID cb_sym_password;
237
+ extern ID cb_sym_periodic;
238
+ extern ID cb_sym_persisted;
239
+ extern ID cb_sym_plain;
240
+ extern ID cb_sym_pool;
241
+ extern ID cb_sym_port;
242
+ extern ID cb_sym_post;
243
+ extern ID cb_sym_prepend;
244
+ extern ID cb_sym_production;
245
+ extern ID cb_sym_put;
246
+ extern ID cb_sym_quiet;
247
+ extern ID cb_sym_replace;
248
+ extern ID cb_sym_replica;
249
+ extern ID cb_sym_select;
250
+ extern ID cb_sym_send_threshold;
251
+ extern ID cb_sym_set;
252
+ extern ID cb_sym_stats;
253
+ extern ID cb_sym_timeout;
254
+ extern ID cb_sym_touch;
255
+ extern ID cb_sym_transcoder;
256
+ extern ID cb_sym_ttl;
257
+ extern ID cb_sym_type;
258
+ extern ID cb_sym_unlock;
259
+ extern ID cb_sym_username;
260
+ extern ID cb_sym_version;
261
+ extern ID cb_sym_view;
262
+ extern ID cb_id_add_shutdown_hook;
263
+ extern ID cb_id_arity;
264
+ extern ID cb_id_call;
265
+ extern ID cb_id_create_timer;
266
+ extern ID cb_id_delete;
267
+ extern ID cb_id_dump;
268
+ extern ID cb_id_dup;
269
+ extern ID cb_id_flatten_bang;
270
+ extern ID cb_id_has_key_p;
271
+ extern ID cb_id_host;
272
+ extern ID cb_id_iv_body;
273
+ extern ID cb_id_iv_cas;
274
+ extern ID cb_id_iv_completed;
275
+ extern ID cb_id_iv_error;
276
+ extern ID cb_id_iv_flags;
277
+ extern ID cb_id_iv_from_master;
278
+ extern ID cb_id_iv_headers;
279
+ extern ID cb_id_iv_inner_exception;
280
+ extern ID cb_id_iv_key;
281
+ extern ID cb_id_iv_node;
282
+ extern ID cb_id_iv_operation;
283
+ extern ID cb_id_iv_status;
284
+ extern ID cb_id_iv_time_to_persist;
285
+ extern ID cb_id_iv_time_to_replicate;
286
+ extern ID cb_id_iv_value;
287
+ extern ID cb_id_load;
288
+ extern ID cb_id_match;
289
+ extern ID cb_id_next_tick;
290
+ extern ID cb_id_observe_and_wait;
291
+ extern ID cb_id_parse;
292
+ extern ID cb_id_parse_body_bang;
293
+ extern ID cb_id_password;
294
+ extern ID cb_id_path;
295
+ extern ID cb_id_port;
296
+ extern ID cb_id_scheme;
297
+ extern ID cb_id_sprintf;
298
+ extern ID cb_id_to_s;
299
+ extern ID cb_id_user;
300
+ extern ID cb_id_verify_observe_options;
301
+
302
+ /* Errors */
303
+ extern VALUE cb_eBaseError;
304
+ extern VALUE cb_eValueFormatError;
305
+ extern VALUE cb_eHTTPError;
306
+ /* LCB_SUCCESS = 0x00 */
307
+ /* LCB_AUTH_CONTINUE = 0x01 */
308
+ extern VALUE cb_eAuthError; /* LCB_AUTH_ERROR = 0x02 */
309
+ extern VALUE cb_eDeltaBadvalError; /* LCB_DELTA_BADVAL = 0x03 */
310
+ extern VALUE cb_eTooBigError; /* LCB_E2BIG = 0x04 */
311
+ extern VALUE cb_eBusyError; /* LCB_EBUSY = 0x05 */
312
+ extern VALUE cb_eInternalError; /* LCB_EINTERNAL = 0x06 */
313
+ extern VALUE cb_eInvalidError; /* LCB_EINVAL = 0x07 */
314
+ extern VALUE cb_eNoMemoryError; /* LCB_ENOMEM = 0x08 */
315
+ extern VALUE cb_eRangeError; /* LCB_ERANGE = 0x09 */
316
+ extern VALUE cb_eLibcouchbaseError; /* LCB_ERROR = 0x0a */
317
+ extern VALUE cb_eTmpFailError; /* LCB_ETMPFAIL = 0x0b */
318
+ extern VALUE cb_eKeyExistsError; /* LCB_KEY_EEXISTS = 0x0c */
319
+ extern VALUE cb_eNotFoundError; /* LCB_KEY_ENOENT = 0x0d */
320
+ extern VALUE cb_eDlopenFailedError; /* LCB_DLOPEN_FAILED = 0x0e */
321
+ extern VALUE cb_eDlsymFailedError; /* LCB_DLSYM_FAILED = 0x0f */
322
+ extern VALUE cb_eNetworkError; /* LCB_NETWORK_ERROR = 0x10 */
323
+ extern VALUE cb_eNotMyVbucketError; /* LCB_NOT_MY_VBUCKET = 0x11 */
324
+ extern VALUE cb_eNotStoredError; /* LCB_NOT_STORED = 0x12 */
325
+ extern VALUE cb_eNotSupportedError; /* LCB_NOT_SUPPORTED = 0x13 */
326
+ extern VALUE cb_eUnknownCommandError; /* LCB_UNKNOWN_COMMAND = 0x14 */
327
+ extern VALUE cb_eUnknownHostError; /* LCB_UNKNOWN_HOST = 0x15 */
328
+ extern VALUE cb_eProtocolError; /* LCB_PROTOCOL_ERROR = 0x16 */
329
+ extern VALUE cb_eTimeoutError; /* LCB_ETIMEDOUT = 0x17 */
330
+ extern VALUE cb_eConnectError; /* LCB_CONNECT_ERROR = 0x18 */
331
+ extern VALUE cb_eBucketNotFoundError; /* LCB_BUCKET_ENOENT = 0x19 */
332
+ extern VALUE cb_eClientNoMemoryError; /* LCB_CLIENT_ENOMEM = 0x1a */
333
+ extern VALUE cb_eClientTmpFailError; /* LCB_CLIENT_ETMPFAIL = 0x1b */
334
+ extern VALUE cb_eBadHandleError; /* LCB_EBADHANDLE = 0x1c */
335
+ extern VALUE cb_eServerBug; /* LCB_SERVER_BUG = 0x1d */
336
+ extern VALUE cb_ePluginVersionMismatch; /* LCB_PLUGIN_VERSION_MISMATCH = 0x1e */
337
+ extern VALUE cb_eInvalidHostFormat; /* LCB_INVALID_HOST_FORMAT = 0x1f */
338
+ extern VALUE cb_eInvalidChar; /* LCB_INVALID_CHAR = 0x20 */
339
+ extern VALUE cb_eDurabilityTooMany; /* LCB_DURABILITY_ETOOMANY = 0x21 */
340
+ extern VALUE cb_eDuplicateCommands; /* LCB_DUPLICATE_COMMANDS = 0x22 */
341
+ extern VALUE cb_eNoMatchingServer; /* LCB_NO_MATCHING_SERVER = 0x23 */
342
+ extern VALUE cb_eBadEnvironment; /* LCB_BAD_ENVIRONMENT = 0x24 */
343
+ extern VALUE cb_eBusy; /* LCB_BUSY = 0x25 */
344
+ extern VALUE cb_eInvalidUsername; /* LCB_INVALID_USERNAME = 0x26 */
345
+
346
+
347
+ /* Default Strings */
348
+ extern VALUE cb_vStrDefault;
349
+ extern VALUE cb_vStrEmpty;
350
+ extern VALUE cb_vStrLocalhost;
351
+
352
+ typedef void (*mark_f)(void *, struct cb_bucket_st*);
353
+ void cb_strip_key_prefix(struct cb_bucket_st *bucket, VALUE key);
354
+ VALUE cb_check_error(lcb_error_t rc, const char *msg, VALUE key);
355
+ VALUE cb_check_error_with_status(lcb_error_t rc, const char *msg, VALUE key, lcb_http_status_t status);
356
+ int cb_bucket_connected_bang(struct cb_bucket_st *bucket, VALUE operation);
357
+ void cb_gc_protect_ptr(struct cb_bucket_st *bucket, void *ptr, mark_f mark_func);
358
+ void cb_gc_unprotect_ptr(struct cb_bucket_st *bucket, void *ptr);
359
+ VALUE cb_proc_call(struct cb_bucket_st *bucket, VALUE recv, int argc, ...);
360
+ int cb_first_value_i(VALUE key, VALUE value, VALUE arg);
361
+ void cb_build_headers(struct cb_context_st *ctx, const char * const *headers);
362
+ void cb_maybe_do_loop(struct cb_bucket_st *bucket);
363
+ VALUE cb_unify_key(struct cb_bucket_st *bucket, VALUE key, int apply_prefix);
364
+ VALUE cb_encode_value(VALUE transcoder, VALUE val, uint32_t *flags, VALUE options);
365
+ VALUE cb_decode_value(VALUE transcoder, VALUE blob, uint32_t flags, VALUE options);
366
+ void cb_async_error_notify(struct cb_bucket_st *bucket, VALUE exc);
367
+
368
+
369
+ void cb_storage_callback(lcb_t handle, const void *cookie, lcb_storage_t operation, lcb_error_t error, const lcb_store_resp_t *resp);
370
+ void cb_get_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_get_resp_t *resp);
371
+ void cb_touch_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_touch_resp_t *resp);
372
+ void cb_delete_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_remove_resp_t *resp);
373
+ void cb_stat_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_server_stat_resp_t *resp);
374
+ void cb_arithmetic_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_arithmetic_resp_t *resp);
375
+ void cb_version_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_server_version_resp_t *resp);
376
+ void cb_http_complete_callback(lcb_http_request_t request, lcb_t handle, const void *cookie, lcb_error_t error, const lcb_http_resp_t *resp);
377
+ void cb_http_data_callback(lcb_http_request_t request, lcb_t handle, const void *cookie, lcb_error_t error, const lcb_http_resp_t *resp);
378
+ void cb_observe_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_observe_resp_t *resp);
379
+ void cb_unlock_callback(lcb_t handle, const void *cookie, lcb_error_t error, const lcb_unlock_resp_t *resp);
380
+
381
+ struct cb_context_st *cb_context_alloc(struct cb_bucket_st *bucket);
382
+ struct cb_context_st *cb_context_alloc_common(struct cb_bucket_st *bucket, VALUE proc, size_t nqueries);
383
+ void cb_context_free(struct cb_context_st *ctx);
384
+
385
+ VALUE cb_bucket_alloc(VALUE klass);
386
+ void cb_bucket_free(void *ptr);
387
+ VALUE cb_bucket_init_copy(VALUE copy, VALUE orig);
388
+ VALUE cb_bucket_init(int argc, VALUE *argv, VALUE self);
389
+ VALUE cb_bucket_inspect(VALUE self);
390
+ VALUE cb_bucket_touch(int argc, VALUE *argv, VALUE self);
391
+ VALUE cb_bucket_delete(int argc, VALUE *argv, VALUE self);
392
+ VALUE cb_bucket_stats(int argc, VALUE *argv, VALUE self);
393
+ VALUE cb_bucket_set(int argc, VALUE *argv, VALUE self);
394
+ VALUE cb_bucket_add(int argc, VALUE *argv, VALUE self);
395
+ VALUE cb_bucket_replace(int argc, VALUE *argv, VALUE self);
396
+ VALUE cb_bucket_append(int argc, VALUE *argv, VALUE self);
397
+ VALUE cb_bucket_prepend(int argc, VALUE *argv, VALUE self);
398
+ VALUE cb_bucket_aset(int argc, VALUE *argv, VALUE self);
399
+ VALUE cb_bucket_get(int argc, VALUE *argv, VALUE self);
400
+ VALUE cb_bucket_incr(int argc, VALUE *argv, VALUE self);
401
+ VALUE cb_bucket_decr(int argc, VALUE *argv, VALUE self);
402
+ VALUE cb_bucket_unlock(int argc, VALUE *argv, VALUE self);
403
+ VALUE cb_bucket_run(int argc, VALUE *argv, VALUE self);
404
+ VALUE cb_bucket_stop(VALUE self);
405
+ VALUE cb_bucket_version(int argc, VALUE *argv, VALUE self);
406
+ VALUE cb_bucket_disconnect(VALUE self);
407
+ VALUE cb_bucket_reconnect(int argc, VALUE *argv, VALUE self);
408
+ VALUE cb_bucket_make_http_request(int argc, VALUE *argv, VALUE self);
409
+ VALUE cb_bucket_observe(int argc, VALUE *argv, VALUE self);
410
+ VALUE cb_bucket_connected_p(VALUE self);
411
+ VALUE cb_bucket_async_p(VALUE self);
412
+ VALUE cb_bucket_quiet_get(VALUE self);
413
+ VALUE cb_bucket_quiet_set(VALUE self, VALUE val);
414
+ VALUE cb_bucket_transcoder_get(VALUE self);
415
+ VALUE cb_bucket_transcoder_set(VALUE self, VALUE val);
416
+ VALUE cb_bucket_default_flags_get(VALUE self);
417
+ VALUE cb_bucket_default_flags_set(VALUE self, VALUE val);
418
+ VALUE cb_bucket_default_format_get(VALUE self);
419
+ VALUE cb_bucket_default_format_set(VALUE self, VALUE val);
420
+ VALUE cb_bucket_on_error_set(VALUE self, VALUE val);
421
+ VALUE cb_bucket_on_error_get(VALUE self);
422
+ VALUE cb_bucket_on_connect_set(VALUE self, VALUE val);
423
+ VALUE cb_bucket_on_connect_get(VALUE self);
424
+ VALUE cb_bucket_timeout_get(VALUE self);
425
+ VALUE cb_bucket_timeout_set(VALUE self, VALUE val);
426
+ VALUE cb_bucket_key_prefix_get(VALUE self);
427
+ VALUE cb_bucket_key_prefix_set(VALUE self, VALUE val);
428
+ VALUE cb_bucket_url_get(VALUE self);
429
+ VALUE cb_bucket_hostname_get(VALUE self);
430
+ VALUE cb_bucket_port_get(VALUE self);
431
+ VALUE cb_bucket_authority_get(VALUE self);
432
+ VALUE cb_bucket_bucket_get(VALUE self);
433
+ VALUE cb_bucket_pool_get(VALUE self);
434
+ VALUE cb_bucket_username_get(VALUE self);
435
+ VALUE cb_bucket_password_get(VALUE self);
436
+ VALUE cb_bucket_environment_get(VALUE self);
437
+ VALUE cb_bucket_num_replicas_get(VALUE self);
438
+ VALUE cb_bucket_default_observe_timeout_get(VALUE self);
439
+ VALUE cb_bucket_default_observe_timeout_set(VALUE self, VALUE val);
440
+ VALUE cb_bucket_default_arithmetic_init_get(VALUE self);
441
+ VALUE cb_bucket_default_arithmetic_init_set(VALUE self, VALUE val);
442
+
443
+ VALUE cb_http_request_alloc(VALUE klass);
444
+ VALUE cb_http_request_init(int argc, VALUE *argv, VALUE self);
445
+ VALUE cb_http_request_inspect(VALUE self);
446
+ VALUE cb_http_request_on_body(VALUE self);
447
+ VALUE cb_http_request_perform(VALUE self);
448
+ VALUE cb_http_request_pause(VALUE self);
449
+ VALUE cb_http_request_continue(VALUE self);
450
+ VALUE cb_http_request_path_get(VALUE self);
451
+ VALUE cb_http_request_extended_get(VALUE self);
452
+ VALUE cb_http_request_chunked_get(VALUE self);
453
+
454
+ VALUE cb_result_success_p(VALUE self);
455
+ VALUE cb_result_inspect(VALUE self);
456
+
457
+ VALUE cb_timer_alloc(VALUE klass);
458
+ VALUE cb_timer_inspect(VALUE self);
459
+ VALUE cb_timer_cancel(VALUE self);
460
+ VALUE cb_timer_init(int argc, VALUE *argv, VALUE self);
461
+
462
+ /* Method arguments */
463
+
464
+ enum cb_command_t {
465
+ cb_cmd_touch = 0x01,
466
+ cb_cmd_remove = 0x02,
467
+ cb_cmd_store = 0x03,
468
+ cb_cmd_get = 0x04,
469
+ cb_cmd_arith = 0x05,
470
+ cb_cmd_stats = 0x06,
471
+ cb_cmd_version = 0x08,
472
+ cb_cmd_observe = 0x09,
473
+ cb_cmd_unlock = 0x10
474
+ };
475
+
476
+ struct cb_params_st
477
+ {
478
+ enum cb_command_t type;
479
+ union {
480
+ struct {
481
+ /* number of items */
482
+ size_t num;
483
+ /* array of the items */
484
+ lcb_touch_cmd_t *items;
485
+ /* array of the pointers to the items */
486
+ const lcb_touch_cmd_t **ptr;
487
+ unsigned int quiet : 1;
488
+ unsigned int array : 1;
489
+ lcb_time_t ttl;
490
+ } touch;
491
+ struct {
492
+ /* number of items */
493
+ size_t num;
494
+ /* array of the items */
495
+ lcb_remove_cmd_t *items;
496
+ /* array of the pointers to the items */
497
+ const lcb_remove_cmd_t **ptr;
498
+ unsigned int array : 1;
499
+ /* 1 if it should silense NOT_FOUND errors */
500
+ unsigned int quiet : 1;
501
+ lcb_cas_t cas;
502
+ } remove;
503
+ struct {
504
+ /* number of items */
505
+ size_t num;
506
+ /* array of the items */
507
+ lcb_store_cmd_t *items;
508
+ /* array of the pointers to the items */
509
+ const lcb_store_cmd_t **ptr;
510
+ lcb_storage_t operation;
511
+ lcb_uint32_t flags;
512
+ lcb_time_t ttl;
513
+ lcb_cas_t cas;
514
+ lcb_datatype_t datatype;
515
+ VALUE observe;
516
+ VALUE transcoder;
517
+ VALUE transcoder_opts;
518
+ } store;
519
+ struct {
520
+ /* number of items */
521
+ size_t num;
522
+ /* array of the items */
523
+ lcb_get_cmd_t *items;
524
+ /* array of the pointers to the items */
525
+ const lcb_get_cmd_t **ptr;
526
+ /* array of the items for GET_REPLICA command */
527
+ lcb_get_replica_cmd_t *items_gr;
528
+ /* array of the pointers to the items for GET_REPLICA command */
529
+ const lcb_get_replica_cmd_t **ptr_gr;
530
+ unsigned int array : 1;
531
+ unsigned int lock : 1;
532
+ unsigned int assemble_hash : 1;
533
+ unsigned int extended : 1;
534
+ unsigned int quiet : 1;
535
+ /* arguments given in form of hash key-ttl to "get and touch" */
536
+ unsigned int gat : 1;
537
+ lcb_time_t ttl;
538
+ VALUE replica;
539
+ VALUE transcoder;
540
+ VALUE transcoder_opts;
541
+ VALUE keys_ary;
542
+ } get;
543
+ struct {
544
+ /* number of items */
545
+ size_t num;
546
+ /* array of the items */
547
+ lcb_arithmetic_cmd_t *items;
548
+ /* array of the pointers to the items */
549
+ const lcb_arithmetic_cmd_t **ptr;
550
+ unsigned int array : 1;
551
+ unsigned int extended : 1;
552
+ unsigned int create : 1;
553
+ lcb_time_t ttl;
554
+ lcb_uint64_t initial;
555
+ lcb_uint64_t delta;
556
+ int sign;
557
+ VALUE transcoder;
558
+ VALUE transcoder_opts;
559
+ lcb_datatype_t datatype;
560
+ } arith;
561
+ struct {
562
+ /* number of items */
563
+ size_t num;
564
+ /* array of the items */
565
+ lcb_server_stats_cmd_t *items;
566
+ /* array of the pointers to the items */
567
+ const lcb_server_stats_cmd_t **ptr;
568
+ unsigned int array : 1;
569
+ } stats;
570
+ struct {
571
+ /* number of items */
572
+ size_t num;
573
+ /* array of the items */
574
+ lcb_server_version_cmd_t *items;
575
+ /* array of the pointers to the items */
576
+ const lcb_server_version_cmd_t **ptr;
577
+ } version;
578
+ struct {
579
+ /* number of items */
580
+ size_t num;
581
+ /* array of the items */
582
+ lcb_observe_cmd_t *items;
583
+ /* array of the pointers to the items */
584
+ const lcb_observe_cmd_t **ptr;
585
+ unsigned int array : 1;
586
+ } observe;
587
+ struct {
588
+ /* number of items */
589
+ size_t num;
590
+ /* array of the items */
591
+ lcb_unlock_cmd_t *items;
592
+ /* array of the pointers to the items */
593
+ const lcb_unlock_cmd_t **ptr;
594
+ unsigned int quiet : 1;
595
+ lcb_cas_t cas;
596
+ } unlock;
597
+ } cmd;
598
+ struct cb_bucket_st *bucket;
599
+ /* helper index for iterators */
600
+ size_t idx;
601
+ /* the approximate size of the data to be sent */
602
+ size_t npayload;
603
+ VALUE ensurance;
604
+ VALUE args;
605
+ };
606
+
607
+ void cb_params_destroy(struct cb_params_st *params);
608
+ void cb_params_build(struct cb_params_st *params);
609
+
610
+ /* common plugin functions */
611
+ lcb_ssize_t cb_io_recv(struct lcb_io_opt_st *iops, lcb_socket_t sock, void *buffer, lcb_size_t len, int flags);
612
+ lcb_ssize_t cb_io_recvv(struct lcb_io_opt_st *iops, lcb_socket_t sock, struct lcb_iovec_st *iov, lcb_size_t niov);
613
+ lcb_ssize_t cb_io_send(struct lcb_io_opt_st *iops, lcb_socket_t sock, const void *msg, lcb_size_t len, int flags);
614
+ lcb_ssize_t cb_io_sendv(struct lcb_io_opt_st *iops, lcb_socket_t sock, struct lcb_iovec_st *iov, lcb_size_t niov);
615
+ lcb_socket_t cb_io_socket(struct lcb_io_opt_st *iops, int domain, int type, int protocol);
616
+ void cb_io_close(struct lcb_io_opt_st *iops, lcb_socket_t sock);
617
+ int cb_io_connect(struct lcb_io_opt_st *iops, lcb_socket_t sock, const struct sockaddr *name, unsigned int namelen);
618
+
619
+ /* plugin init functions */
620
+ LIBCOUCHBASE_API
621
+ lcb_error_t cb_create_ruby_mt_io_opts(int version, lcb_io_opt_t *io, void *arg);
622
+
623
+ /* shortcut functions */
624
+ static inline VALUE
625
+ rb_funcall_0(VALUE self, ID method)
626
+ {
627
+ return rb_funcall2(self, method, 0, NULL);
628
+ }
629
+
630
+ static inline VALUE
631
+ rb_funcall_1(VALUE self, ID method, VALUE arg)
632
+ {
633
+ return rb_funcall2(self, method, 1, &arg);
634
+ }
635
+
636
+ static inline VALUE
637
+ rb_funcall_2(VALUE self, ID method, VALUE arg1, VALUE arg2)
638
+ {
639
+ VALUE args[2] = {arg1, arg2};
640
+ return rb_funcall2(self, method, 2, args);
641
+ }
642
+
643
+ #endif
644
+