couchbase 1.3.4-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +22 -0
- data/.yardopts +5 -0
- data/CONTRIBUTING.markdown +75 -0
- data/Gemfile +4 -0
- data/LICENSE +201 -0
- data/Makefile +3 -0
- data/README.markdown +649 -0
- data/RELEASE_NOTES.markdown +796 -0
- data/Rakefile +20 -0
- data/couchbase.gemspec +49 -0
- data/examples/chat-em/Gemfile +7 -0
- data/examples/chat-em/README.markdown +45 -0
- data/examples/chat-em/server.rb +82 -0
- data/examples/chat-goliath-grape/Gemfile +5 -0
- data/examples/chat-goliath-grape/README.markdown +50 -0
- data/examples/chat-goliath-grape/app.rb +67 -0
- data/examples/chat-goliath-grape/config/app.rb +20 -0
- data/examples/transcoders/Gemfile +3 -0
- data/examples/transcoders/README.markdown +59 -0
- data/examples/transcoders/cb-zcat +40 -0
- data/examples/transcoders/cb-zcp +45 -0
- data/examples/transcoders/gzip_transcoder.rb +49 -0
- data/examples/transcoders/options.rb +54 -0
- data/ext/couchbase_ext/.gitignore +4 -0
- data/ext/couchbase_ext/arguments.c +956 -0
- data/ext/couchbase_ext/arithmetic.c +307 -0
- data/ext/couchbase_ext/bucket.c +1370 -0
- data/ext/couchbase_ext/context.c +65 -0
- data/ext/couchbase_ext/couchbase_ext.c +1364 -0
- data/ext/couchbase_ext/couchbase_ext.h +644 -0
- data/ext/couchbase_ext/delete.c +163 -0
- data/ext/couchbase_ext/eventmachine_plugin.c +452 -0
- data/ext/couchbase_ext/extconf.rb +168 -0
- data/ext/couchbase_ext/get.c +316 -0
- data/ext/couchbase_ext/gethrtime.c +129 -0
- data/ext/couchbase_ext/http.c +432 -0
- data/ext/couchbase_ext/multithread_plugin.c +1090 -0
- data/ext/couchbase_ext/observe.c +171 -0
- data/ext/couchbase_ext/plugin_common.c +171 -0
- data/ext/couchbase_ext/result.c +129 -0
- data/ext/couchbase_ext/stats.c +163 -0
- data/ext/couchbase_ext/store.c +542 -0
- data/ext/couchbase_ext/timer.c +192 -0
- data/ext/couchbase_ext/touch.c +186 -0
- data/ext/couchbase_ext/unlock.c +176 -0
- data/ext/couchbase_ext/utils.c +551 -0
- data/ext/couchbase_ext/version.c +142 -0
- data/lib/action_dispatch/middleware/session/couchbase_store.rb +38 -0
- data/lib/active_support/cache/couchbase_store.rb +430 -0
- data/lib/couchbase.rb +155 -0
- data/lib/couchbase/bucket.rb +457 -0
- data/lib/couchbase/cluster.rb +119 -0
- data/lib/couchbase/connection_pool.rb +58 -0
- data/lib/couchbase/constants.rb +12 -0
- data/lib/couchbase/result.rb +26 -0
- data/lib/couchbase/transcoder.rb +120 -0
- data/lib/couchbase/utils.rb +62 -0
- data/lib/couchbase/version.rb +21 -0
- data/lib/couchbase/view.rb +506 -0
- data/lib/couchbase/view_row.rb +272 -0
- data/lib/ext/multi_json_fix.rb +56 -0
- data/lib/rack/session/couchbase.rb +108 -0
- data/tasks/benchmark.rake +6 -0
- data/tasks/compile.rake +158 -0
- data/tasks/test.rake +100 -0
- data/tasks/util.rake +21 -0
- data/test/profile/.gitignore +1 -0
- data/test/profile/Gemfile +6 -0
- data/test/profile/benchmark.rb +195 -0
- data/test/setup.rb +178 -0
- data/test/test_arithmetic.rb +185 -0
- data/test/test_async.rb +316 -0
- data/test/test_bucket.rb +250 -0
- data/test/test_cas.rb +235 -0
- data/test/test_couchbase.rb +77 -0
- data/test/test_couchbase_connection_pool.rb +77 -0
- data/test/test_couchbase_rails_cache_store.rb +361 -0
- data/test/test_delete.rb +120 -0
- data/test/test_errors.rb +82 -0
- data/test/test_eventmachine.rb +70 -0
- data/test/test_format.rb +164 -0
- data/test/test_get.rb +407 -0
- data/test/test_stats.rb +57 -0
- data/test/test_store.rb +216 -0
- data/test/test_timer.rb +42 -0
- data/test/test_touch.rb +97 -0
- data/test/test_unlock.rb +119 -0
- data/test/test_utils.rb +58 -0
- data/test/test_version.rb +52 -0
- metadata +336 -0
@@ -0,0 +1,65 @@
|
|
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
|
+
|
18
|
+
#include "couchbase_ext.h"
|
19
|
+
|
20
|
+
static void
|
21
|
+
cb_context_mark(void *p, struct cb_bucket_st* bucket)
|
22
|
+
{
|
23
|
+
struct cb_context_st *ctx = p;
|
24
|
+
rb_gc_mark(ctx->proc);
|
25
|
+
rb_gc_mark(ctx->rv);
|
26
|
+
rb_gc_mark(ctx->exception);
|
27
|
+
rb_gc_mark(ctx->observe_options);
|
28
|
+
rb_gc_mark(ctx->transcoder);
|
29
|
+
rb_gc_mark(ctx->transcoder_opts);
|
30
|
+
rb_gc_mark(ctx->operation);
|
31
|
+
rb_gc_mark(ctx->headers_val);
|
32
|
+
(void)bucket;
|
33
|
+
}
|
34
|
+
|
35
|
+
struct cb_context_st *
|
36
|
+
cb_context_alloc(struct cb_bucket_st* bucket)
|
37
|
+
{
|
38
|
+
struct cb_context_st *ctx = calloc(1, sizeof(*ctx));
|
39
|
+
if (ctx == NULL) {
|
40
|
+
rb_raise(cb_eClientNoMemoryError, "failed to allocate memory for context");
|
41
|
+
}
|
42
|
+
cb_gc_protect_ptr(bucket, ctx, cb_context_mark);
|
43
|
+
ctx->bucket = bucket;
|
44
|
+
ctx->exception = Qnil;
|
45
|
+
return ctx;
|
46
|
+
}
|
47
|
+
|
48
|
+
struct cb_context_st *
|
49
|
+
cb_context_alloc_common(struct cb_bucket_st *bucket, VALUE proc, size_t nqueries)
|
50
|
+
{
|
51
|
+
struct cb_context_st *ctx = cb_context_alloc(bucket);
|
52
|
+
ctx->proc = proc;
|
53
|
+
ctx->nqueries = nqueries;
|
54
|
+
if (!bucket->async) {
|
55
|
+
ctx->rv = rb_hash_new();
|
56
|
+
}
|
57
|
+
return ctx;
|
58
|
+
}
|
59
|
+
|
60
|
+
void
|
61
|
+
cb_context_free(struct cb_context_st *ctx)
|
62
|
+
{
|
63
|
+
cb_gc_unprotect_ptr(ctx->bucket, ctx);
|
64
|
+
free(ctx);
|
65
|
+
}
|
@@ -0,0 +1,1364 @@
|
|
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
|
+
|
18
|
+
|
19
|
+
#include "couchbase_ext.h"
|
20
|
+
|
21
|
+
/* Classes */
|
22
|
+
VALUE cb_cBucket;
|
23
|
+
VALUE cb_cCouchRequest;
|
24
|
+
VALUE cb_cResult;
|
25
|
+
VALUE cb_cTimer;
|
26
|
+
|
27
|
+
/* Modules */
|
28
|
+
VALUE cb_mCouchbase;
|
29
|
+
VALUE cb_mError;
|
30
|
+
VALUE cb_mTranscoder;
|
31
|
+
VALUE cb_mDocument;
|
32
|
+
VALUE cb_mPlain;
|
33
|
+
VALUE cb_mMarshal;
|
34
|
+
VALUE cb_mURI;
|
35
|
+
VALUE em_m;
|
36
|
+
|
37
|
+
/* Symbols */
|
38
|
+
ID cb_sym_add;
|
39
|
+
ID cb_sym_all;
|
40
|
+
ID cb_sym_append;
|
41
|
+
ID cb_sym_assemble_hash;
|
42
|
+
ID cb_sym_async;
|
43
|
+
ID cb_sym_body;
|
44
|
+
ID cb_sym_bucket;
|
45
|
+
ID cb_sym_cas;
|
46
|
+
ID cb_sym_chunked;
|
47
|
+
ID cb_sym_cluster;
|
48
|
+
ID cb_sym_connect;
|
49
|
+
ID cb_sym_content_type;
|
50
|
+
ID cb_sym_create;
|
51
|
+
ID cb_sym_decrement;
|
52
|
+
ID cb_sym_default;
|
53
|
+
ID cb_sym_default_arithmetic_init;
|
54
|
+
ID cb_sym_default_flags;
|
55
|
+
ID cb_sym_default_format;
|
56
|
+
ID cb_sym_default_observe_timeout;
|
57
|
+
ID cb_sym_default_ttl;
|
58
|
+
ID cb_sym_delete;
|
59
|
+
ID cb_sym_delta;
|
60
|
+
ID cb_sym_development;
|
61
|
+
ID cb_sym_document;
|
62
|
+
ID cb_sym_engine;
|
63
|
+
ID cb_sym_environment;
|
64
|
+
ID cb_sym_eventmachine;
|
65
|
+
ID cb_sym_extended;
|
66
|
+
ID cb_sym_first;
|
67
|
+
ID cb_sym_flags;
|
68
|
+
ID cb_sym_forced;
|
69
|
+
ID cb_sym_format;
|
70
|
+
ID cb_sym_found;
|
71
|
+
ID cb_sym_get;
|
72
|
+
ID cb_sym_hostname;
|
73
|
+
ID cb_sym_http_request;
|
74
|
+
ID cb_sym_increment;
|
75
|
+
ID cb_sym_initial;
|
76
|
+
ID cb_sym_iocp;
|
77
|
+
ID cb_sym_key_prefix;
|
78
|
+
ID cb_sym_libev;
|
79
|
+
ID cb_sym_libevent;
|
80
|
+
ID cb_sym_lock;
|
81
|
+
ID cb_sym_management;
|
82
|
+
ID cb_sym_marshal;
|
83
|
+
ID cb_sym_method;
|
84
|
+
ID cb_sym_node_list;
|
85
|
+
ID cb_sym_not_found;
|
86
|
+
ID cb_sym_num_replicas;
|
87
|
+
ID cb_sym_observe;
|
88
|
+
ID cb_sym_password;
|
89
|
+
ID cb_sym_periodic;
|
90
|
+
ID cb_sym_persisted;
|
91
|
+
ID cb_sym_plain;
|
92
|
+
ID cb_sym_pool;
|
93
|
+
ID cb_sym_port;
|
94
|
+
ID cb_sym_post;
|
95
|
+
ID cb_sym_prepend;
|
96
|
+
ID cb_sym_production;
|
97
|
+
ID cb_sym_put;
|
98
|
+
ID cb_sym_quiet;
|
99
|
+
ID cb_sym_replace;
|
100
|
+
ID cb_sym_replica;
|
101
|
+
ID cb_sym_select;
|
102
|
+
ID cb_sym_send_threshold;
|
103
|
+
ID cb_sym_set;
|
104
|
+
ID cb_sym_stats;
|
105
|
+
ID cb_sym_timeout;
|
106
|
+
ID cb_sym_touch;
|
107
|
+
ID cb_sym_transcoder;
|
108
|
+
ID cb_sym_ttl;
|
109
|
+
ID cb_sym_type;
|
110
|
+
ID cb_sym_unlock;
|
111
|
+
ID cb_sym_username;
|
112
|
+
ID cb_sym_version;
|
113
|
+
ID cb_sym_view;
|
114
|
+
ID cb_id_add_shutdown_hook;
|
115
|
+
ID cb_id_arity;
|
116
|
+
ID cb_id_call;
|
117
|
+
ID cb_id_create_timer;
|
118
|
+
ID cb_id_delete;
|
119
|
+
ID cb_id_dump;
|
120
|
+
ID cb_id_dup;
|
121
|
+
ID cb_id_flatten_bang;
|
122
|
+
ID cb_id_has_key_p;
|
123
|
+
ID cb_id_host;
|
124
|
+
ID cb_id_iv_body;
|
125
|
+
ID cb_id_iv_cas;
|
126
|
+
ID cb_id_iv_completed;
|
127
|
+
ID cb_id_iv_error;
|
128
|
+
ID cb_id_iv_flags;
|
129
|
+
ID cb_id_iv_from_master;
|
130
|
+
ID cb_id_iv_headers;
|
131
|
+
ID cb_id_iv_inner_exception;
|
132
|
+
ID cb_id_iv_key;
|
133
|
+
ID cb_id_iv_node;
|
134
|
+
ID cb_id_iv_operation;
|
135
|
+
ID cb_id_iv_status;
|
136
|
+
ID cb_id_iv_time_to_persist;
|
137
|
+
ID cb_id_iv_time_to_replicate;
|
138
|
+
ID cb_id_iv_value;
|
139
|
+
ID cb_id_load;
|
140
|
+
ID cb_id_match;
|
141
|
+
ID cb_id_next_tick;
|
142
|
+
ID cb_id_observe_and_wait;
|
143
|
+
ID cb_id_parse;
|
144
|
+
ID cb_id_parse_body_bang;
|
145
|
+
ID cb_id_password;
|
146
|
+
ID cb_id_path;
|
147
|
+
ID cb_id_port;
|
148
|
+
ID cb_id_scheme;
|
149
|
+
ID cb_id_sprintf;
|
150
|
+
ID cb_id_to_s;
|
151
|
+
ID cb_id_user;
|
152
|
+
ID cb_id_verify_observe_options;
|
153
|
+
|
154
|
+
/* Errors */
|
155
|
+
VALUE cb_eBaseError;
|
156
|
+
VALUE cb_eValueFormatError;
|
157
|
+
VALUE cb_eHTTPError;
|
158
|
+
|
159
|
+
/* LCB_SUCCESS = 0x00 */
|
160
|
+
/* LCB_AUTH_CONTINUE = 0x01 */
|
161
|
+
VALUE cb_eAuthError; /* LCB_AUTH_ERROR = 0x02 */
|
162
|
+
VALUE cb_eDeltaBadvalError; /* LCB_DELTA_BADVAL = 0x03 */
|
163
|
+
VALUE cb_eTooBigError; /* LCB_E2BIG = 0x04 */
|
164
|
+
VALUE cb_eBusyError; /* LCB_EBUSY = 0x05 */
|
165
|
+
VALUE cb_eInternalError; /* LCB_EINTERNAL = 0x06 */
|
166
|
+
VALUE cb_eInvalidError; /* LCB_EINVAL = 0x07 */
|
167
|
+
VALUE cb_eNoMemoryError; /* LCB_ENOMEM = 0x08 */
|
168
|
+
VALUE cb_eRangeError; /* LCB_ERANGE = 0x09 */
|
169
|
+
VALUE cb_eLibcouchbaseError; /* LCB_ERROR = 0x0a */
|
170
|
+
VALUE cb_eTmpFailError; /* LCB_ETMPFAIL = 0x0b */
|
171
|
+
VALUE cb_eKeyExistsError; /* LCB_KEY_EEXISTS = 0x0c */
|
172
|
+
VALUE cb_eNotFoundError; /* LCB_KEY_ENOENT = 0x0d */
|
173
|
+
VALUE cb_eDlopenFailedError; /* LCB_DLOPEN_FAILED = 0x0e */
|
174
|
+
VALUE cb_eDlsymFailedError; /* LCB_DLSYM_FAILED = 0x0f */
|
175
|
+
VALUE cb_eNetworkError; /* LCB_NETWORK_ERROR = 0x10 */
|
176
|
+
VALUE cb_eNotMyVbucketError; /* LCB_NOT_MY_VBUCKET = 0x11 */
|
177
|
+
VALUE cb_eNotStoredError; /* LCB_NOT_STORED = 0x12 */
|
178
|
+
VALUE cb_eNotSupportedError; /* LCB_NOT_SUPPORTED = 0x13 */
|
179
|
+
VALUE cb_eUnknownCommandError; /* LCB_UNKNOWN_COMMAND = 0x14 */
|
180
|
+
VALUE cb_eUnknownHostError; /* LCB_UNKNOWN_HOST = 0x15 */
|
181
|
+
VALUE cb_eProtocolError; /* LCB_PROTOCOL_ERROR = 0x16 */
|
182
|
+
VALUE cb_eTimeoutError; /* LCB_ETIMEDOUT = 0x17 */
|
183
|
+
VALUE cb_eConnectError; /* LCB_CONNECT_ERROR = 0x18 */
|
184
|
+
VALUE cb_eBucketNotFoundError; /* LCB_BUCKET_ENOENT = 0x19 */
|
185
|
+
VALUE cb_eClientNoMemoryError; /* LCB_CLIENT_ENOMEM = 0x1a */
|
186
|
+
VALUE cb_eClientTmpFailError; /* LCB_CLIENT_ETMPFAIL = 0x1b */
|
187
|
+
VALUE cb_eBadHandleError; /* LCB_EBADHANDLE = 0x1c */
|
188
|
+
VALUE cb_eServerBug; /* LCB_SERVER_BUG = 0x1d */
|
189
|
+
VALUE cb_ePluginVersionMismatch; /* LCB_PLUGIN_VERSION_MISMATCH = 0x1e */
|
190
|
+
VALUE cb_eInvalidHostFormat; /* LCB_INVALID_HOST_FORMAT = 0x1f */
|
191
|
+
VALUE cb_eInvalidChar; /* LCB_INVALID_CHAR = 0x20 */
|
192
|
+
VALUE cb_eDurabilityTooMany; /* LCB_DURABILITY_ETOOMANY = 0x21 */
|
193
|
+
VALUE cb_eDuplicateCommands; /* LCB_DUPLICATE_COMMANDS = 0x22 */
|
194
|
+
VALUE cb_eNoMatchingServer; /* LCB_NO_MATCHING_SERVER = 0x23 */
|
195
|
+
VALUE cb_eBadEnvironment; /* LCB_BAD_ENVIRONMENT = 0x24 */
|
196
|
+
VALUE cb_eBusy; /* LCB_BUSY = 0x25 */
|
197
|
+
VALUE cb_eInvalidUsername; /* LCB_INVALID_USERNAME = 0x26 */
|
198
|
+
|
199
|
+
/* Default Strings */
|
200
|
+
VALUE cb_vStrDefault;
|
201
|
+
VALUE cb_vStrEmpty;
|
202
|
+
VALUE cb_vStrLocalhost;
|
203
|
+
|
204
|
+
static VALUE
|
205
|
+
cb_intern_string(VALUE ar, const char *str)
|
206
|
+
{
|
207
|
+
VALUE tmp = STR_NEW_CSTR(str);
|
208
|
+
rb_str_freeze(tmp);
|
209
|
+
rb_ary_push(ar, tmp);
|
210
|
+
return tmp;
|
211
|
+
}
|
212
|
+
|
213
|
+
static VALUE
|
214
|
+
cb_libcouchbase_version(VALUE self)
|
215
|
+
{
|
216
|
+
const char *ver = lcb_get_version(NULL);
|
217
|
+
(void)self;
|
218
|
+
return STR_NEW_CSTR(ver);
|
219
|
+
}
|
220
|
+
|
221
|
+
/* Ruby Extension initializer */
|
222
|
+
void
|
223
|
+
Init_couchbase_ext(void)
|
224
|
+
{
|
225
|
+
VALUE interned;
|
226
|
+
|
227
|
+
/* just a holder for EventMachine module */
|
228
|
+
em_m = 0;
|
229
|
+
|
230
|
+
cb_mURI = rb_const_get(rb_cObject, rb_intern("URI"));
|
231
|
+
cb_mCouchbase = rb_define_module("Couchbase");
|
232
|
+
/* Document-method: libcouchbase_version
|
233
|
+
*
|
234
|
+
* @since 1.3.3
|
235
|
+
*
|
236
|
+
* Version of the libcouchbase library currently loaded
|
237
|
+
* @return [String]
|
238
|
+
*/
|
239
|
+
rb_define_singleton_method(cb_mCouchbase, "libcouchbase_version", cb_libcouchbase_version, 0);
|
240
|
+
|
241
|
+
cb_mTranscoder = rb_const_get(cb_mCouchbase, rb_intern("Transcoder"));
|
242
|
+
cb_mDocument = rb_const_get(cb_mTranscoder, rb_intern("Document"));
|
243
|
+
cb_mMarshal = rb_const_get(cb_mTranscoder, rb_intern("Marshal"));
|
244
|
+
cb_mPlain = rb_const_get(cb_mTranscoder, rb_intern("Plain"));
|
245
|
+
|
246
|
+
cb_mError = rb_define_module_under(cb_mCouchbase, "Error");
|
247
|
+
/* Document-class: Couchbase::Error::Base
|
248
|
+
* The base error class
|
249
|
+
*
|
250
|
+
* @since 1.0.0
|
251
|
+
*/
|
252
|
+
cb_eBaseError = rb_define_class_under(cb_mError, "Base", rb_eStandardError);
|
253
|
+
/* Document-class: Couchbase::Error::Auth
|
254
|
+
* Authentication error
|
255
|
+
*
|
256
|
+
* You provided an invalid username/password combination.
|
257
|
+
*
|
258
|
+
* @since 1.0.0
|
259
|
+
*/
|
260
|
+
cb_eAuthError = rb_define_class_under(cb_mError, "Auth", cb_eBaseError);
|
261
|
+
/* Document-class: Couchbase::Error::BucketNotFound
|
262
|
+
* Bucket not found
|
263
|
+
*
|
264
|
+
* The requested bucket not found in the cluster
|
265
|
+
*
|
266
|
+
* @since 1.0.0
|
267
|
+
*/
|
268
|
+
cb_eBucketNotFoundError = rb_define_class_under(cb_mError, "BucketNotFound", cb_eBaseError);
|
269
|
+
/* Document-class: Couchbase::Error::Busy
|
270
|
+
* The cluster is too busy
|
271
|
+
*
|
272
|
+
* The server is too busy to handle your request right now.
|
273
|
+
* please back off and try again at a later time.
|
274
|
+
*
|
275
|
+
* @since 1.0.0
|
276
|
+
*/
|
277
|
+
cb_eBusyError = rb_define_class_under(cb_mError, "Busy", cb_eBaseError);
|
278
|
+
/* Document-class: Couchbase::Error::DeltaBadval
|
279
|
+
* The given value is not a number
|
280
|
+
*
|
281
|
+
* @since 1.0.0
|
282
|
+
*/
|
283
|
+
cb_eDeltaBadvalError = rb_define_class_under(cb_mError, "DeltaBadval", cb_eBaseError);
|
284
|
+
/* Document-class: Couchbase::Error::Internal
|
285
|
+
* Internal error
|
286
|
+
*
|
287
|
+
* Internal error inside the library. You would have
|
288
|
+
* to destroy the instance and create a new one to recover.
|
289
|
+
*
|
290
|
+
* @since 1.0.0
|
291
|
+
*/
|
292
|
+
cb_eInternalError = rb_define_class_under(cb_mError, "Internal", cb_eBaseError);
|
293
|
+
/* Document-class: Couchbase::Error::Invalid
|
294
|
+
* Invalid arguments
|
295
|
+
*
|
296
|
+
* @since 1.0.0
|
297
|
+
*/
|
298
|
+
cb_eInvalidError = rb_define_class_under(cb_mError, "Invalid", cb_eBaseError);
|
299
|
+
/* Document-class: Couchbase::Error::KeyExists
|
300
|
+
* Key already exists
|
301
|
+
*
|
302
|
+
* The key already exists (with another CAS value)
|
303
|
+
*
|
304
|
+
* @since 1.0.0
|
305
|
+
*/
|
306
|
+
cb_eKeyExistsError = rb_define_class_under(cb_mError, "KeyExists", cb_eBaseError);
|
307
|
+
/* Document-class: Couchbase::Error::Libcouchbase
|
308
|
+
* Generic error
|
309
|
+
*
|
310
|
+
* @since 1.0.0
|
311
|
+
*/
|
312
|
+
cb_eLibcouchbaseError = rb_define_class_under(cb_mError, "Libcouchbase", cb_eBaseError);
|
313
|
+
/* Document-class: Couchbase::Error::Network
|
314
|
+
* Network error
|
315
|
+
*
|
316
|
+
* A network related problem occured (name lookup, read/write/connect
|
317
|
+
* etc)
|
318
|
+
*
|
319
|
+
* @since 1.0.0
|
320
|
+
*/
|
321
|
+
cb_eNetworkError = rb_define_class_under(cb_mError, "Network", cb_eBaseError);
|
322
|
+
/* Document-class: Couchbase::Error::NoMemory
|
323
|
+
* Out of memory error (on Server)
|
324
|
+
*
|
325
|
+
* @since 1.0.0
|
326
|
+
*/
|
327
|
+
cb_eNoMemoryError = rb_define_class_under(cb_mError, "NoMemory", cb_eBaseError);
|
328
|
+
/* Document-class: Couchbase::Error::ClientNoMemory
|
329
|
+
* Out of memory error (on Client)
|
330
|
+
*
|
331
|
+
* @since 1.2.0.dp6
|
332
|
+
*/
|
333
|
+
cb_eClientNoMemoryError = rb_define_class_under(cb_mError, "ClientNoMemory", cb_eBaseError);
|
334
|
+
/* Document-class: Couchbase::Error::NotFound
|
335
|
+
* No such key
|
336
|
+
*
|
337
|
+
* @since 1.0.0
|
338
|
+
*/
|
339
|
+
cb_eNotFoundError = rb_define_class_under(cb_mError, "NotFound", cb_eBaseError);
|
340
|
+
/* Document-class: Couchbase::Error::NotMyVbucket
|
341
|
+
* The vbucket is not located on this server
|
342
|
+
*
|
343
|
+
* The server who received the request is not responsible for the
|
344
|
+
* object anymore. (This happens during changes in the cluster
|
345
|
+
* topology)
|
346
|
+
*
|
347
|
+
* @since 1.0.0
|
348
|
+
*/
|
349
|
+
cb_eNotMyVbucketError = rb_define_class_under(cb_mError, "NotMyVbucket", cb_eBaseError);
|
350
|
+
/* Document-class: Couchbase::Error::NotStored
|
351
|
+
* Not stored
|
352
|
+
*
|
353
|
+
* The object was not stored on the server
|
354
|
+
*
|
355
|
+
* @since 1.0.0
|
356
|
+
*/
|
357
|
+
cb_eNotStoredError = rb_define_class_under(cb_mError, "NotStored", cb_eBaseError);
|
358
|
+
/* Document-class: Couchbase::Error::NotSupported
|
359
|
+
* Not supported
|
360
|
+
*
|
361
|
+
* The server doesn't support the requested command. This error differs
|
362
|
+
* from {Couchbase::Error::UnknownCommand} by that the server knows
|
363
|
+
* about the command, but for some reason decided to not support it.
|
364
|
+
*
|
365
|
+
* @since 1.0.0
|
366
|
+
*/
|
367
|
+
cb_eNotSupportedError = rb_define_class_under(cb_mError, "NotSupported", cb_eBaseError);
|
368
|
+
/* Document-class: Couchbase::Error::Range
|
369
|
+
* Invalid range
|
370
|
+
*
|
371
|
+
* An invalid range specified
|
372
|
+
*
|
373
|
+
* @since 1.0.0
|
374
|
+
*/
|
375
|
+
cb_eRangeError = rb_define_class_under(cb_mError, "Range", cb_eBaseError);
|
376
|
+
/* Document-class: Couchbase::Error::TemporaryFail
|
377
|
+
* Temporary failure
|
378
|
+
*
|
379
|
+
* The server tried to perform the requested operation, but failed
|
380
|
+
* due to a temporary constraint. Retrying the operation may work.
|
381
|
+
*
|
382
|
+
* @since 1.0.0
|
383
|
+
*/
|
384
|
+
cb_eTmpFailError = rb_define_class_under(cb_mError, "TemporaryFail", cb_eBaseError);
|
385
|
+
/* Document-class: Couchbase::Error::ClientTemporaryFail
|
386
|
+
* Temporary failure (on Client)
|
387
|
+
*
|
388
|
+
* The client encountered a temporary error (retry might resolve
|
389
|
+
* the problem)
|
390
|
+
*
|
391
|
+
* @since 1.2.0
|
392
|
+
*/
|
393
|
+
cb_eClientTmpFailError = rb_define_class_under(cb_mError, "ClientTemporaryFail", cb_eBaseError);
|
394
|
+
/* Document-class: Couchbase::Error::TooBig
|
395
|
+
* Object too big
|
396
|
+
*
|
397
|
+
* The sever reported that this object is too big
|
398
|
+
*
|
399
|
+
* @since 1.0.0
|
400
|
+
*/
|
401
|
+
cb_eTooBigError = rb_define_class_under(cb_mError, "TooBig", cb_eBaseError);
|
402
|
+
/* Document-class: Couchbase::Error::UnknownCommand
|
403
|
+
* Unknown command
|
404
|
+
*
|
405
|
+
* The server doesn't know what that command is.
|
406
|
+
*
|
407
|
+
* @since 1.0.0
|
408
|
+
*/
|
409
|
+
cb_eUnknownCommandError = rb_define_class_under(cb_mError, "UnknownCommand", cb_eBaseError);
|
410
|
+
/* Document-class: Couchbase::Error::UnknownHost
|
411
|
+
* Unknown host
|
412
|
+
*
|
413
|
+
* The server failed to resolve the requested hostname
|
414
|
+
*
|
415
|
+
* @since 1.0.0
|
416
|
+
*/
|
417
|
+
cb_eUnknownHostError = rb_define_class_under(cb_mError, "UnknownHost", cb_eBaseError);
|
418
|
+
/* Document-class: Couchbase::Error::ValueFormat
|
419
|
+
* Failed to decode or encode value
|
420
|
+
*
|
421
|
+
* @since 1.0.0
|
422
|
+
*/
|
423
|
+
cb_eValueFormatError = rb_define_class_under(cb_mError, "ValueFormat", cb_eBaseError);
|
424
|
+
/* Document-class: Couchbase::Error::Protocol
|
425
|
+
* Protocol error
|
426
|
+
*
|
427
|
+
* There is something wrong with the datastream received from
|
428
|
+
* the server
|
429
|
+
*
|
430
|
+
* @since 1.0.0
|
431
|
+
*/
|
432
|
+
cb_eProtocolError = rb_define_class_under(cb_mError, "Protocol", cb_eBaseError);
|
433
|
+
/* Document-class: Couchbase::Error::Timeout
|
434
|
+
* Timeout error
|
435
|
+
*
|
436
|
+
* The operation timed out
|
437
|
+
*
|
438
|
+
* @since 1.1.0
|
439
|
+
*/
|
440
|
+
cb_eTimeoutError = rb_define_class_under(cb_mError, "Timeout", cb_eBaseError);
|
441
|
+
/* Document-class: Couchbase::Error::Connect
|
442
|
+
* Connect error
|
443
|
+
*
|
444
|
+
* @since 1.1.0
|
445
|
+
*/
|
446
|
+
cb_eConnectError = rb_define_class_under(cb_mError, "Connect", cb_eBaseError);
|
447
|
+
/* Document-class: Couchbase::Error::BadHandle
|
448
|
+
* Invalid handle type.
|
449
|
+
*
|
450
|
+
* The requested operation isn't allowed for given type.
|
451
|
+
*
|
452
|
+
* @since 1.2.0
|
453
|
+
*/
|
454
|
+
cb_eBadHandleError = rb_define_class_under(cb_mError, "BadHandle", cb_eBaseError);
|
455
|
+
|
456
|
+
/* Document-class: Couchbase::Error::DlopenFailed
|
457
|
+
* dlopen() failed
|
458
|
+
*
|
459
|
+
* Failed to open shared object
|
460
|
+
*
|
461
|
+
* @since 1.2.0
|
462
|
+
*/
|
463
|
+
cb_eDlopenFailedError = rb_define_class_under(cb_mError, "DlopenFailed", cb_eBaseError);
|
464
|
+
|
465
|
+
/* Document-class: Couchbase::Error::DlsymFailed
|
466
|
+
* dlsym() failed
|
467
|
+
*
|
468
|
+
* Failed to locate the requested symbol in the shared object
|
469
|
+
*
|
470
|
+
* @since 1.2.0
|
471
|
+
*/
|
472
|
+
cb_eDlsymFailedError = rb_define_class_under(cb_mError, "DlsymFailed", cb_eBaseError);
|
473
|
+
|
474
|
+
/* Document-class: Couchbase::Error::ServerBug
|
475
|
+
* Server Bug
|
476
|
+
*
|
477
|
+
* Unexpected usage of the server protocol, like unexpected
|
478
|
+
* response. If you've received this error code, please record your
|
479
|
+
* steps and file the issue at:
|
480
|
+
*
|
481
|
+
* http://www.couchbase.com/issues/browse/MB
|
482
|
+
*
|
483
|
+
* @since 1.3.3
|
484
|
+
*/
|
485
|
+
cb_eServerBug = rb_define_class_under(cb_mError, "ServerBug", cb_eBaseError);
|
486
|
+
|
487
|
+
/* Document-class: Couchbase::Error::PluginVersionMismatch
|
488
|
+
* Plugin Version Mismatch
|
489
|
+
*
|
490
|
+
* Libcouchbase cannot load the plugin because of version mismatch
|
491
|
+
*
|
492
|
+
* @since 1.3.3
|
493
|
+
*/
|
494
|
+
cb_ePluginVersionMismatch = rb_define_class_under(cb_mError, "PluginVersionMismatch", cb_eBaseError);
|
495
|
+
|
496
|
+
/* Document-class: Couchbase::Error::InvalidHostFormat
|
497
|
+
* Invalid Host Format
|
498
|
+
*
|
499
|
+
* The bootstrap hosts list use an invalid/unsupported format
|
500
|
+
*
|
501
|
+
* @since 1.3.3
|
502
|
+
*/
|
503
|
+
cb_eInvalidHostFormat = rb_define_class_under(cb_mError, "InvalidHostFormat", cb_eBaseError);
|
504
|
+
|
505
|
+
/* Document-class: Couchbase::Error::InvalidChar
|
506
|
+
* Invalid Character
|
507
|
+
*
|
508
|
+
* Invalid character used in the path component of an URL
|
509
|
+
*
|
510
|
+
* @since 1.3.3
|
511
|
+
*/
|
512
|
+
cb_eInvalidChar = rb_define_class_under(cb_mError, "InvalidChar", cb_eBaseError);
|
513
|
+
|
514
|
+
/* Document-class: Couchbase::Error::DurabilityTooMany
|
515
|
+
* Too Many Nodes
|
516
|
+
*
|
517
|
+
* Too many nodes were requested for the observe criteria
|
518
|
+
*
|
519
|
+
* @since 1.3.3
|
520
|
+
*/
|
521
|
+
cb_eDurabilityTooMany = rb_define_class_under(cb_mError, "DurabilityTooMany", cb_eBaseError);
|
522
|
+
|
523
|
+
/* Document-class: Couchbase::Error::DuplicateCommands
|
524
|
+
* Duplicate Commands
|
525
|
+
*
|
526
|
+
* The same key was passed multiple times in a command list
|
527
|
+
*
|
528
|
+
* @since 1.3.3
|
529
|
+
*/
|
530
|
+
cb_eDuplicateCommands = rb_define_class_under(cb_mError, "DuplicateCommands", cb_eBaseError);
|
531
|
+
|
532
|
+
/* Document-class: Couchbase::Error::NoMatchingServer
|
533
|
+
* No Matching Server
|
534
|
+
*
|
535
|
+
* The config says that there is no server yet at that
|
536
|
+
* position (-1 in the cluster topology map)
|
537
|
+
*
|
538
|
+
* @since 1.3.3
|
539
|
+
*/
|
540
|
+
cb_eNoMatchingServer = rb_define_class_under(cb_mError, "NoMatchingServer", cb_eBaseError);
|
541
|
+
|
542
|
+
/* Document-class: Couchbase::Error::BadEnvironment
|
543
|
+
* Busy
|
544
|
+
*
|
545
|
+
* An operation has not yet completed
|
546
|
+
*
|
547
|
+
* @since 1.3.3
|
548
|
+
*/
|
549
|
+
cb_eBadEnvironment = rb_define_class_under(cb_mError, "BadEnvironment", cb_eBaseError);
|
550
|
+
|
551
|
+
/* Document-class: Couchbase::Error::Busy
|
552
|
+
* Invalid Character
|
553
|
+
*
|
554
|
+
* Invalid character used in the path component of an URL
|
555
|
+
*
|
556
|
+
* @since 1.3.3
|
557
|
+
*/
|
558
|
+
cb_eBusy = rb_define_class_under(cb_mError, "Busy", cb_eBaseError);
|
559
|
+
|
560
|
+
/* Document-class: Couchbase::Error::InvalidUsername
|
561
|
+
* Invalid Username
|
562
|
+
*
|
563
|
+
* Administrator account must not be used to access the data
|
564
|
+
* in the bucket
|
565
|
+
*
|
566
|
+
* @since 1.3.3
|
567
|
+
*/
|
568
|
+
cb_eInvalidUsername = rb_define_class_under(cb_mError, "InvalidUsername", cb_eBaseError);
|
569
|
+
|
570
|
+
/* Document-class: Couchbase::Error::HTTP
|
571
|
+
* HTTP error with status code
|
572
|
+
*
|
573
|
+
* @since 1.2.0
|
574
|
+
*/
|
575
|
+
cb_eHTTPError = rb_define_class_under(cb_mError, "HTTP", cb_eBaseError);
|
576
|
+
cb_id_iv_body = rb_intern("@body");
|
577
|
+
/* Document-method: error
|
578
|
+
*
|
579
|
+
* The underlying libcouchbase library could return one of the following
|
580
|
+
* error codes. The ruby client will wrap these errors into appropriate
|
581
|
+
* exception class, derived from {Couchbase::Error::Base}.
|
582
|
+
*
|
583
|
+
* 0x00 :: LCB_SUCCESS (Success)
|
584
|
+
* 0x01 :: LCB_AUTH_CONTINUE (Continue authentication)
|
585
|
+
* 0x02 :: LCB_AUTH_ERROR (Authentication error)
|
586
|
+
* 0x03 :: LCB_DELTA_BADVAL (Not a number)
|
587
|
+
* 0x04 :: LCB_E2BIG (Object too big)
|
588
|
+
* 0x05 :: LCB_EBUSY (Too busy)
|
589
|
+
* 0x06 :: LCB_EINTERNAL (Internal error)
|
590
|
+
* 0x07 :: LCB_EINVAL (Invalid arguments)
|
591
|
+
* 0x08 :: LCB_ENOMEM (Out of memory)
|
592
|
+
* 0x09 :: LCB_ERANGE (Invalid range)
|
593
|
+
* 0x0a :: LCB_ERROR (Generic error)
|
594
|
+
* 0x0b :: LCB_ETMPFAIL (Temporary failure)
|
595
|
+
* 0x0c :: LCB_KEY_EEXISTS (Key exists (with a different CAS value))
|
596
|
+
* 0x0d :: LCB_KEY_ENOENT (No such key)
|
597
|
+
* 0x0e :: LCB_DLOPEN_FAILED (Failed to open shared object)
|
598
|
+
* 0x0f :: LCB_DLSYM_FAILED (Failed to locate the requested cb_symbol in shared object)
|
599
|
+
* 0x10 :: LCB_NETWORK_ERROR (Network error)
|
600
|
+
* 0x11 :: LCB_NOT_MY_VBUCKET (The vbucket is not located on this server)
|
601
|
+
* 0x12 :: LCB_NOT_STORED (Not stored)
|
602
|
+
* 0x13 :: LCB_NOT_SUPPORTED (Not supported)
|
603
|
+
* 0x14 :: LCB_UNKNOWN_COMMAND (Unknown command)
|
604
|
+
* 0x15 :: LCB_UNKNOWN_HOST (Unknown host)
|
605
|
+
* 0x16 :: LCB_PROTOCOL_ERROR (Protocol error)
|
606
|
+
* 0x17 :: LCB_ETIMEDOUT (Operation timed out)
|
607
|
+
* 0x18 :: LCB_CONNECT_ERROR (Connection failure)
|
608
|
+
* 0x19 :: LCB_BUCKET_ENOENT (No such bucket)
|
609
|
+
* 0x1a :: LCB_CLIENT_ENOMEM (Out of memory on the client)
|
610
|
+
* 0x1b :: LCB_CLIENT_ETMPFAIL (Temporary failure on the client)
|
611
|
+
* 0x1c :: LCB_EBADHANDLE (Invalid handle type)
|
612
|
+
* 0x1d :: LCB_SERVER_BUG (Server bug)
|
613
|
+
* 0x1e :: LCB_PLUGIN_VERSION_MISMATCH (Plugin version mismatch)
|
614
|
+
* 0x1f :: LCB_INVALID_HOST_FORMAT (Invalid host format)
|
615
|
+
* 0x20 :: LCB_INVALID_CHAR (Invalid character)
|
616
|
+
*
|
617
|
+
* @since 1.0.0
|
618
|
+
*
|
619
|
+
* @return [Fixnum] the error code from libcouchbase
|
620
|
+
*/
|
621
|
+
rb_define_attr(cb_eBaseError, "error", 1, 0);
|
622
|
+
cb_id_iv_error = rb_intern("@error");
|
623
|
+
/* Document-method: status
|
624
|
+
*
|
625
|
+
* @since 1.2.0.beta
|
626
|
+
*
|
627
|
+
* @return [Fixnum] The HTTP status code */
|
628
|
+
rb_define_attr(cb_eBaseError, "status", 1, 0);
|
629
|
+
cb_id_iv_status = rb_intern("@status");
|
630
|
+
/* Document-method: key
|
631
|
+
*
|
632
|
+
* @since 1.0.0
|
633
|
+
*
|
634
|
+
* @return [String] the key which generated error */
|
635
|
+
rb_define_attr(cb_eBaseError, "key", 1, 0);
|
636
|
+
cb_id_iv_key = rb_intern("@key");
|
637
|
+
/* Document-method: cas
|
638
|
+
*
|
639
|
+
* @since 1.0.0
|
640
|
+
*
|
641
|
+
* @return [Fixnum] the version of the key (+nil+ unless accessible) */
|
642
|
+
rb_define_attr(cb_eBaseError, "cas", 1, 0);
|
643
|
+
cb_id_iv_cas = rb_intern("@cas");
|
644
|
+
/* Document-method: operation
|
645
|
+
*
|
646
|
+
* @since 1.0.0
|
647
|
+
*
|
648
|
+
* @return [Symbol] the operation (+nil+ unless accessible) */
|
649
|
+
rb_define_attr(cb_eBaseError, "operation", 1, 0);
|
650
|
+
cb_id_iv_operation = rb_intern("@operation");
|
651
|
+
/* Document-method: inner_exception
|
652
|
+
*
|
653
|
+
* @since 1.2.0.beta4
|
654
|
+
*
|
655
|
+
* @return [Exception] the inner exception or +nil+. Some exceptions like
|
656
|
+
* {Error::ValueFormat} wrap the original exception */
|
657
|
+
rb_define_attr(cb_eBaseError, "inner_exception", 1, 0);
|
658
|
+
cb_id_iv_inner_exception = rb_intern("@inner_exception");
|
659
|
+
|
660
|
+
/* Document-class: Couchbase::Result
|
661
|
+
*
|
662
|
+
* The object which yielded to asynchronous callbacks
|
663
|
+
*
|
664
|
+
* @since 1.0.0
|
665
|
+
*/
|
666
|
+
cb_cResult = rb_define_class_under(cb_mCouchbase, "Result", rb_cObject);
|
667
|
+
rb_define_method(cb_cResult, "inspect", cb_result_inspect, 0);
|
668
|
+
rb_define_method(cb_cResult, "to_s", cb_result_inspect, 0);
|
669
|
+
rb_define_method(cb_cResult, "success?", cb_result_success_p, 0);
|
670
|
+
/* Document-method: operation
|
671
|
+
*
|
672
|
+
* @since 1.0.0
|
673
|
+
*
|
674
|
+
* @return [Symbol]
|
675
|
+
*/
|
676
|
+
rb_define_attr(cb_cResult, "operation", 1, 0);
|
677
|
+
/* Document-method: error
|
678
|
+
*
|
679
|
+
* @since 1.0.0
|
680
|
+
*
|
681
|
+
* @return [Couchbase::Error::Base]
|
682
|
+
*/
|
683
|
+
rb_define_attr(cb_cResult, "error", 1, 0);
|
684
|
+
/* Document-method: key
|
685
|
+
*
|
686
|
+
* @since 1.0.0
|
687
|
+
*
|
688
|
+
* @return [String]
|
689
|
+
*/
|
690
|
+
rb_define_attr(cb_cResult, "key", 1, 0);
|
691
|
+
cb_id_iv_key = rb_intern("@key");
|
692
|
+
/* Document-method: value
|
693
|
+
*
|
694
|
+
* @since 1.0.0
|
695
|
+
*
|
696
|
+
* @return [String]
|
697
|
+
*/
|
698
|
+
rb_define_attr(cb_cResult, "value", 1, 0);
|
699
|
+
rb_define_alias(cb_cResult, "bucket", "value");
|
700
|
+
cb_id_iv_value = rb_intern("@value");
|
701
|
+
/* Document-method: cas
|
702
|
+
*
|
703
|
+
* @since 1.0.0
|
704
|
+
*
|
705
|
+
* @return [Fixnum]
|
706
|
+
*/
|
707
|
+
rb_define_attr(cb_cResult, "cas", 1, 0);
|
708
|
+
cb_id_iv_cas = rb_intern("@cas");
|
709
|
+
/* Document-method: flags
|
710
|
+
*
|
711
|
+
* @since 1.0.0
|
712
|
+
*
|
713
|
+
* @return [Fixnum]
|
714
|
+
*/
|
715
|
+
rb_define_attr(cb_cResult, "flags", 1, 0);
|
716
|
+
cb_id_iv_flags = rb_intern("@flags");
|
717
|
+
/* Document-method: node
|
718
|
+
*
|
719
|
+
* @since 1.0.0
|
720
|
+
*
|
721
|
+
* @return [String]
|
722
|
+
*/
|
723
|
+
rb_define_attr(cb_cResult, "node", 1, 0);
|
724
|
+
cb_id_iv_node = rb_intern("@node");
|
725
|
+
/* Document-method: headers
|
726
|
+
*
|
727
|
+
* @since 1.2.0
|
728
|
+
*
|
729
|
+
* HTTP headers
|
730
|
+
*
|
731
|
+
* @return [Hash]
|
732
|
+
*/
|
733
|
+
rb_define_attr(cb_cResult, "headers", 1, 0);
|
734
|
+
cb_id_iv_headers = rb_intern("@headers");
|
735
|
+
/* Document-method: completed
|
736
|
+
* In {Bucket::CouchRequest} operations used to mark the final call
|
737
|
+
* @return [Boolean] */
|
738
|
+
rb_define_attr(cb_cResult, "completed", 1, 0);
|
739
|
+
rb_define_alias(cb_cResult, "completed?", "completed");
|
740
|
+
cb_id_iv_completed = rb_intern("@completed");
|
741
|
+
/* Document-method: status
|
742
|
+
*
|
743
|
+
* @since 1.2.0.dp6
|
744
|
+
*
|
745
|
+
* @see Bucket#observe
|
746
|
+
*
|
747
|
+
* Status of the key. Possible values:
|
748
|
+
* +:found+ :: Key found in cache, but not yet persisted
|
749
|
+
* +:persisted+ :: Key found and persisted
|
750
|
+
* +:not_found+ :: Key not found
|
751
|
+
*
|
752
|
+
* @return [Symbol]
|
753
|
+
*/
|
754
|
+
rb_define_attr(cb_cResult, "status", 1, 0);
|
755
|
+
cb_id_iv_status = rb_intern("@status");
|
756
|
+
/* Document-method: from_master
|
757
|
+
*
|
758
|
+
* @since 1.2.0.dp6
|
759
|
+
*
|
760
|
+
* @see Bucket#observe
|
761
|
+
*
|
762
|
+
* True if key stored on master
|
763
|
+
* @return [Boolean]
|
764
|
+
*/
|
765
|
+
rb_define_attr(cb_cResult, "from_master", 1, 0);
|
766
|
+
rb_define_alias(cb_cResult, "from_master?", "from_master");
|
767
|
+
cb_id_iv_from_master = rb_intern("@from_master");
|
768
|
+
/* Document-method: time_to_persist
|
769
|
+
*
|
770
|
+
* @since 1.2.0.dp6
|
771
|
+
*
|
772
|
+
* @see Bucket#observe
|
773
|
+
*
|
774
|
+
* Average time needed to persist key on the disk (zero if unavailable)
|
775
|
+
* @return [Fixnum]
|
776
|
+
*/
|
777
|
+
rb_define_attr(cb_cResult, "time_to_persist", 1, 0);
|
778
|
+
rb_define_alias(cb_cResult, "ttp", "time_to_persist");
|
779
|
+
cb_id_iv_time_to_persist = rb_intern("@time_to_persist");
|
780
|
+
/* Document-method: time_to_persist
|
781
|
+
*
|
782
|
+
* @since 1.2.0.dp6
|
783
|
+
*
|
784
|
+
* @see Bucket#observe
|
785
|
+
*
|
786
|
+
* Average time needed to replicate key on the disk (zero if unavailable)
|
787
|
+
* @return [Fixnum]
|
788
|
+
*/
|
789
|
+
rb_define_attr(cb_cResult, "time_to_replicate", 1, 0);
|
790
|
+
rb_define_alias(cb_cResult, "ttr", "time_to_replicate");
|
791
|
+
cb_id_iv_time_to_replicate = rb_intern("@time_to_replicate");
|
792
|
+
|
793
|
+
/* Document-class: Couchbase::Bucket
|
794
|
+
*
|
795
|
+
* This class in charge of all stuff connected to communication with
|
796
|
+
* Couchbase.
|
797
|
+
*
|
798
|
+
* @since 1.0.0
|
799
|
+
*/
|
800
|
+
cb_cBucket = rb_define_class_under(cb_mCouchbase, "Bucket", rb_cObject);
|
801
|
+
|
802
|
+
/* 0x03: Bitmask for flag bits responsible for format */
|
803
|
+
rb_define_const(cb_cBucket, "FMT_MASK", INT2FIX(CB_FMT_MASK));
|
804
|
+
/* 0x00: Document format. The (default) format supports most of ruby
|
805
|
+
* types which could be mapped to JSON data (hashes, arrays, strings,
|
806
|
+
* numbers). Future version will be able to run map/reduce queries on
|
807
|
+
* the values in the document form (hashes). */
|
808
|
+
rb_define_const(cb_cBucket, "FMT_DOCUMENT", INT2FIX(CB_FMT_DOCUMENT));
|
809
|
+
/* 0x01: Marshal format. The format which supports transparent
|
810
|
+
* serialization of ruby objects with standard <tt>Marshal.dump</tt> and
|
811
|
+
* <tt>Marhal.load</tt> methods. */
|
812
|
+
rb_define_const(cb_cBucket, "FMT_MARSHAL", INT2FIX(CB_FMT_MARSHAL));
|
813
|
+
/* 0x02: Plain format. The format which force client don't apply any
|
814
|
+
* conversions to the value, but it should be passed as String. It
|
815
|
+
* could be useful for building custom algorithms or formats. For
|
816
|
+
* example implement set:
|
817
|
+
* http://dustin.github.com/2011/02/17/memcached-set.html */
|
818
|
+
rb_define_const(cb_cBucket, "FMT_PLAIN", INT2FIX(CB_FMT_PLAIN));
|
819
|
+
|
820
|
+
rb_define_alloc_func(cb_cBucket, cb_bucket_alloc);
|
821
|
+
rb_define_method(cb_cBucket, "initialize", cb_bucket_init, -1);
|
822
|
+
rb_define_method(cb_cBucket, "initialize_copy", cb_bucket_init_copy, 1);
|
823
|
+
rb_define_method(cb_cBucket, "inspect", cb_bucket_inspect, 0);
|
824
|
+
|
825
|
+
rb_define_method(cb_cBucket, "add", cb_bucket_add, -1);
|
826
|
+
rb_define_method(cb_cBucket, "append", cb_bucket_append, -1);
|
827
|
+
rb_define_method(cb_cBucket, "prepend", cb_bucket_prepend, -1);
|
828
|
+
rb_define_method(cb_cBucket, "replace", cb_bucket_replace, -1);
|
829
|
+
rb_define_method(cb_cBucket, "set", cb_bucket_set, -1);
|
830
|
+
rb_define_method(cb_cBucket, "get", cb_bucket_get, -1);
|
831
|
+
rb_define_method(cb_cBucket, "run", cb_bucket_run, -1);
|
832
|
+
rb_define_method(cb_cBucket, "stop", cb_bucket_stop, 0);
|
833
|
+
rb_define_method(cb_cBucket, "touch", cb_bucket_touch, -1);
|
834
|
+
rb_define_method(cb_cBucket, "delete", cb_bucket_delete, -1);
|
835
|
+
rb_define_method(cb_cBucket, "stats", cb_bucket_stats, -1);
|
836
|
+
rb_define_method(cb_cBucket, "version", cb_bucket_version, -1);
|
837
|
+
rb_define_method(cb_cBucket, "incr", cb_bucket_incr, -1);
|
838
|
+
rb_define_method(cb_cBucket, "decr", cb_bucket_decr, -1);
|
839
|
+
rb_define_method(cb_cBucket, "unlock", cb_bucket_unlock, -1);
|
840
|
+
rb_define_method(cb_cBucket, "disconnect", cb_bucket_disconnect, 0);
|
841
|
+
rb_define_method(cb_cBucket, "reconnect", cb_bucket_reconnect, -1);
|
842
|
+
rb_define_method(cb_cBucket, "make_http_request", cb_bucket_make_http_request, -1);
|
843
|
+
rb_define_method(cb_cBucket, "observe", cb_bucket_observe, -1);
|
844
|
+
|
845
|
+
rb_define_alias(cb_cBucket, "decrement", "decr");
|
846
|
+
rb_define_alias(cb_cBucket, "increment", "incr");
|
847
|
+
|
848
|
+
rb_define_alias(cb_cBucket, "[]", "get");
|
849
|
+
rb_define_alias(cb_cBucket, "[]=", "set");
|
850
|
+
rb_define_method(cb_cBucket, "[]=", cb_bucket_aset, -1);
|
851
|
+
|
852
|
+
rb_define_method(cb_cBucket, "connected?", cb_bucket_connected_p, 0);
|
853
|
+
rb_define_method(cb_cBucket, "async?", cb_bucket_async_p, 0);
|
854
|
+
|
855
|
+
/* Document-method: quiet
|
856
|
+
* Flag specifying behaviour for operations on missing keys
|
857
|
+
*
|
858
|
+
* @since 1.0.0
|
859
|
+
*
|
860
|
+
* If it is +true+, the operations will silently return +nil+ or +false+
|
861
|
+
* instead of raising {Couchbase::Error::NotFound}.
|
862
|
+
*
|
863
|
+
* @example Hiding cache miss (considering "miss" key is not stored)
|
864
|
+
* connection.quiet = true
|
865
|
+
* connection.get("miss") #=> nil
|
866
|
+
*
|
867
|
+
* @example Raising errors on miss (considering "miss" key is not stored)
|
868
|
+
* connection.quiet = false
|
869
|
+
* connection.get("miss") #=> will raise Couchbase::Error::NotFound
|
870
|
+
*
|
871
|
+
* @return [true, false] */
|
872
|
+
/* rb_define_attr(cb_cBucket, "quiet", 1, 1); */
|
873
|
+
rb_define_method(cb_cBucket, "quiet", cb_bucket_quiet_get, 0);
|
874
|
+
rb_define_method(cb_cBucket, "quiet=", cb_bucket_quiet_set, 1);
|
875
|
+
rb_define_alias(cb_cBucket, "quiet?", "quiet");
|
876
|
+
|
877
|
+
/* Document-method: default_flags
|
878
|
+
* Default flags for new values.
|
879
|
+
*
|
880
|
+
* @since 1.0.0
|
881
|
+
*
|
882
|
+
* The library reserves last two lower bits to store the format of the
|
883
|
+
* value. The can be masked via FMT_MASK constant.
|
884
|
+
*
|
885
|
+
* @example Selecting format bits
|
886
|
+
* connection.default_flags & Couchbase::Bucket::FMT_MASK
|
887
|
+
*
|
888
|
+
* @example Set user defined bits
|
889
|
+
* connection.default_flags |= 0x6660
|
890
|
+
*
|
891
|
+
* @note Amending format bit will also change #default_format value
|
892
|
+
*
|
893
|
+
* @return [Fixnum] the effective flags */
|
894
|
+
/* rb_define_attr(cb_cBucket, "default_flags", 1, 1); */
|
895
|
+
rb_define_method(cb_cBucket, "default_flags", cb_bucket_default_flags_get, 0);
|
896
|
+
rb_define_method(cb_cBucket, "default_flags=", cb_bucket_default_flags_set, 1);
|
897
|
+
|
898
|
+
/* Document-method: transcoder
|
899
|
+
* Set data transcoder for the current connection
|
900
|
+
*
|
901
|
+
* @since 1.2.4
|
902
|
+
*
|
903
|
+
* It is possible to define custom transcoder to handle all value
|
904
|
+
* transformation, for example, if you need to adopt legacy
|
905
|
+
* application. The transcoder should respond to two methods:
|
906
|
+
* +dump+ and +load+. They are accepting the data itself, the
|
907
|
+
* flags field, and the options hash from the library.
|
908
|
+
*
|
909
|
+
* @example Simple data transcoder, which use Zlib to compress documents
|
910
|
+
* class ZlibTranscoder
|
911
|
+
* FMT_ZLIB = 0x04
|
912
|
+
*
|
913
|
+
* def initialize(base)
|
914
|
+
* @base = base
|
915
|
+
* end
|
916
|
+
*
|
917
|
+
* def dump(obj, flags, options = {})
|
918
|
+
* obj, flags = @base.dump(obj, flags, options)
|
919
|
+
* z = Zlib::Deflate.new(Zlib::BEST_SPEED)
|
920
|
+
* buffer = z.deflate(obj, Zlib::FINISH)
|
921
|
+
* z.close
|
922
|
+
* [buffer, flags|FMT_ZLIB]
|
923
|
+
* end
|
924
|
+
*
|
925
|
+
* def load(blob, flags, options = {})
|
926
|
+
* # decompress value only if Zlib flag set
|
927
|
+
* if (flags & FMT_ZLIB) == FMT_ZLIB
|
928
|
+
* z = Zlib::Inflate.new
|
929
|
+
* blob = z.inflate(blob)
|
930
|
+
* z.finish
|
931
|
+
* z.close
|
932
|
+
* end
|
933
|
+
* @base.load(blob, flags, options)
|
934
|
+
* end
|
935
|
+
* end
|
936
|
+
*
|
937
|
+
* @return [Object] the data transcoder */
|
938
|
+
/* rb_define_attr(cb_cBucket, "transcoder", 1, 1); */
|
939
|
+
rb_define_method(cb_cBucket, "transcoder", cb_bucket_transcoder_get, 0);
|
940
|
+
rb_define_method(cb_cBucket, "transcoder=", cb_bucket_transcoder_set, 1);
|
941
|
+
|
942
|
+
/* Document-method: default_format
|
943
|
+
* Default format for new values.
|
944
|
+
*
|
945
|
+
* @since 1.0.0
|
946
|
+
*
|
947
|
+
* @see http://couchbase.com/docs/couchbase-manual-2.0/couchbase-views-datastore.html
|
948
|
+
*
|
949
|
+
* It uses flags field to store the format. It accepts either the Symbol
|
950
|
+
* (+:document+, +:marshal+, +:plain+) or Fixnum (use constants
|
951
|
+
* FMT_DOCUMENT, FMT_MARSHAL, FMT_PLAIN) and silently ignores all
|
952
|
+
* other value.
|
953
|
+
*
|
954
|
+
* Here is some notes regarding how to choose the format:
|
955
|
+
*
|
956
|
+
* * <tt>:document</tt> (default) format supports most of ruby types
|
957
|
+
* which could be mapped to JSON data (hashes, arrays, strings,
|
958
|
+
* numbers). Future version will be able to run map/reduce queries on
|
959
|
+
* the values in the document form (hashes).
|
960
|
+
*
|
961
|
+
* * <tt>:plain</tt> format if you no need any conversions to be applied
|
962
|
+
* to your data, but your data should be passed as String. It could be
|
963
|
+
* useful for building custom algorithms or formats. For example
|
964
|
+
* implement set: http://dustin.github.com/2011/02/17/memcached-set.html
|
965
|
+
*
|
966
|
+
* * <tt>:marshal</tt> format if you'd like to transparently serialize
|
967
|
+
* your ruby object with standard <tt>Marshal.dump</tt> and
|
968
|
+
* <tt>Marhal.load</tt> methods.
|
969
|
+
*
|
970
|
+
* @example Selecting 'plain' format using symbol
|
971
|
+
* connection.default_format = :plain
|
972
|
+
*
|
973
|
+
* @example Selecting plain format using Fixnum constant (deprecated)
|
974
|
+
* connection.default_format = Couchbase::Bucket::FMT_PLAIN
|
975
|
+
*
|
976
|
+
* @note Amending default_format will also change #default_flags value
|
977
|
+
*
|
978
|
+
* @return [Symbol] the effective format */
|
979
|
+
/* rb_define_attr(cb_cBucket, "default_format", 1, 1); */
|
980
|
+
rb_define_method(cb_cBucket, "default_format", cb_bucket_default_format_get, 0);
|
981
|
+
rb_define_method(cb_cBucket, "default_format=", cb_bucket_default_format_set, 1);
|
982
|
+
|
983
|
+
/* Document-method: timeout
|
984
|
+
*
|
985
|
+
* @since 1.1.0
|
986
|
+
*
|
987
|
+
* @return [Fixnum] The timeout for the operations in microseconds. The
|
988
|
+
* client will raise {Couchbase::Error::Timeout} exception for all
|
989
|
+
* commands which weren't completed in given timeslot. */
|
990
|
+
/* rb_define_attr(cb_cBucket, "timeout", 1, 1); */
|
991
|
+
rb_define_method(cb_cBucket, "timeout", cb_bucket_timeout_get, 0);
|
992
|
+
rb_define_method(cb_cBucket, "timeout=", cb_bucket_timeout_set, 1);
|
993
|
+
|
994
|
+
/* Document-method: default_arithmetic_init
|
995
|
+
*
|
996
|
+
* @since 1.2.0
|
997
|
+
*
|
998
|
+
* @return [Fixnum, true] The initial value for arithmetic operations
|
999
|
+
* {Bucket#incr} and {Bucket#decr}. Setting this attribute will force
|
1000
|
+
* aforementioned operations create keys unless they exists in the
|
1001
|
+
* bucket and will use given value. You can also just specify +true+
|
1002
|
+
* if you'd like just force key creation with zero default value.
|
1003
|
+
*/
|
1004
|
+
/* rb_define_attr(cb_cBucket, "default_arithmetic_init", 1, 1); */
|
1005
|
+
rb_define_method(cb_cBucket, "default_arithmetic_init", cb_bucket_default_arithmetic_init_get, 0);
|
1006
|
+
rb_define_method(cb_cBucket, "default_arithmetic_init=", cb_bucket_default_arithmetic_init_set, 1);
|
1007
|
+
|
1008
|
+
/* Document-method: key_prefix
|
1009
|
+
*
|
1010
|
+
* @since 1.2.0.dp5
|
1011
|
+
*
|
1012
|
+
* @return [String] The library will prepend +key_prefix+ to each key to
|
1013
|
+
* provide simple namespacing. */
|
1014
|
+
/* rb_define_attr(cb_cBucket, "key_prefix", 1, 1); */
|
1015
|
+
rb_define_method(cb_cBucket, "key_prefix", cb_bucket_key_prefix_get, 0);
|
1016
|
+
rb_define_method(cb_cBucket, "key_prefix=", cb_bucket_key_prefix_set, 1);
|
1017
|
+
|
1018
|
+
/* Document-method: on_error
|
1019
|
+
* Error callback for asynchronous mode.
|
1020
|
+
*
|
1021
|
+
* @since 1.0.0
|
1022
|
+
*
|
1023
|
+
* This callback is using to deliver exceptions in asynchronous mode.
|
1024
|
+
*
|
1025
|
+
* @yieldparam [Exception] exc The exception instance
|
1026
|
+
*
|
1027
|
+
* @example Using lambda syntax
|
1028
|
+
* connection = Couchbase.connect
|
1029
|
+
* connection.on_error = lambda {|exc| ... }
|
1030
|
+
* connection.run do |conn|
|
1031
|
+
* conn.set("foo", "bar")
|
1032
|
+
* end
|
1033
|
+
*
|
1034
|
+
* @example Using block syntax
|
1035
|
+
* connection = Couchbase.connect
|
1036
|
+
* connection.on_error {|exc| ... }
|
1037
|
+
* connection.run do |conn|
|
1038
|
+
* conn.set("foo", "bar")
|
1039
|
+
* end
|
1040
|
+
*
|
1041
|
+
* @return [Proc] the effective callback */
|
1042
|
+
/* rb_define_attr(cb_cBucket, "on_error", 1, 1); */
|
1043
|
+
rb_define_method(cb_cBucket, "on_error", cb_bucket_on_error_get, 0);
|
1044
|
+
rb_define_method(cb_cBucket, "on_error=", cb_bucket_on_error_set, 1);
|
1045
|
+
|
1046
|
+
/* Document-method: on_connect
|
1047
|
+
* Connection callback for asynchronous mode.
|
1048
|
+
*
|
1049
|
+
* @since 1.3.0
|
1050
|
+
*
|
1051
|
+
* This callback used to notify that bucket instance is connected
|
1052
|
+
* and ready to handle requests in asynchronous mode.
|
1053
|
+
*
|
1054
|
+
* @yieldparam [Result] result The result instance, with valid
|
1055
|
+
* properties +#error+, +#success?+, +#operation+ and +#bucket+
|
1056
|
+
*
|
1057
|
+
* @example Using lambda syntax
|
1058
|
+
* connection = Couchbase.new(:async => true)
|
1059
|
+
* connection.on_connect = lambda do |ret|
|
1060
|
+
* if ret.success?
|
1061
|
+
* conn.set("foo", "bar")
|
1062
|
+
* end
|
1063
|
+
* end
|
1064
|
+
* connection.run
|
1065
|
+
*
|
1066
|
+
* @example Using block syntax
|
1067
|
+
* connection = Couchbase.new(:async => true)
|
1068
|
+
* connection.run do |conn|
|
1069
|
+
* connection.on_connect do |ret|
|
1070
|
+
* if ret.success?
|
1071
|
+
* conn.set("foo", "bar")
|
1072
|
+
* end
|
1073
|
+
* end
|
1074
|
+
* end
|
1075
|
+
*
|
1076
|
+
* @example
|
1077
|
+
* EM.run do
|
1078
|
+
* pool = Pool.new
|
1079
|
+
* connection = Couchbase.new(:engine => :eventmachine, :async => true)
|
1080
|
+
* connection.on_connect do |result|
|
1081
|
+
* unless result.success?
|
1082
|
+
* $stderr.puts "Could not connect to CouchBase #{result.error}"
|
1083
|
+
* else
|
1084
|
+
* pool.add result.bucket
|
1085
|
+
* end
|
1086
|
+
* end
|
1087
|
+
* end
|
1088
|
+
*
|
1089
|
+
* @example
|
1090
|
+
* EM.run do
|
1091
|
+
* pool = Pool.new
|
1092
|
+
* connection = Couchbase.new(:engine => :eventmachine, :async => true)
|
1093
|
+
* connection.on_connect = pool.method(:couchbase_connect_callback)
|
1094
|
+
* end
|
1095
|
+
*
|
1096
|
+
* @return [Proc] the effective callback */
|
1097
|
+
/* rb_define_attr(cb_cBucket, "on_connect", 1, 1); */
|
1098
|
+
rb_define_method(cb_cBucket, "on_connect", cb_bucket_on_connect_get, 0);
|
1099
|
+
rb_define_method(cb_cBucket, "on_connect=", cb_bucket_on_connect_set, 1);
|
1100
|
+
|
1101
|
+
/* Document-method: url
|
1102
|
+
*
|
1103
|
+
* The config url for this connection.
|
1104
|
+
*
|
1105
|
+
* Generally it is the bootstrap URL, but it could be different after
|
1106
|
+
* cluster upgrade. This url is used to fetch the cluster
|
1107
|
+
* configuration.
|
1108
|
+
*
|
1109
|
+
* @since 1.0.0
|
1110
|
+
*
|
1111
|
+
* @return [String] the address of the cluster management interface
|
1112
|
+
*/
|
1113
|
+
/* rb_define_attr(cb_cBucket, "url", 1, 0); */
|
1114
|
+
rb_define_method(cb_cBucket, "url", cb_bucket_url_get, 0);
|
1115
|
+
/* Document-method: hostname
|
1116
|
+
*
|
1117
|
+
* The hostname of the current node
|
1118
|
+
*
|
1119
|
+
* @see Bucket#url
|
1120
|
+
*
|
1121
|
+
* @since 1.0.0
|
1122
|
+
*
|
1123
|
+
* @return [String] the host name of the management interface (default: "localhost")
|
1124
|
+
*/
|
1125
|
+
/* rb_define_attr(cb_cBucket, "hostname", 1, 0); */
|
1126
|
+
rb_define_method(cb_cBucket, "hostname", cb_bucket_hostname_get, 0);
|
1127
|
+
/* Document-method: port
|
1128
|
+
*
|
1129
|
+
* The port of the current node
|
1130
|
+
*
|
1131
|
+
* @see Bucket#url
|
1132
|
+
*
|
1133
|
+
* @since 1.0.0
|
1134
|
+
*
|
1135
|
+
* @return [Fixnum] the port number of the management interface (default: 8091)
|
1136
|
+
*/
|
1137
|
+
/* rb_define_attr(cb_cBucket, "port", 1, 0); */
|
1138
|
+
rb_define_method(cb_cBucket, "port", cb_bucket_port_get, 0);
|
1139
|
+
/* Document-method: authority
|
1140
|
+
*
|
1141
|
+
* The authority ("hostname:port") of the current node
|
1142
|
+
*
|
1143
|
+
* @see Bucket#url
|
1144
|
+
*
|
1145
|
+
* @since 1.0.0
|
1146
|
+
*
|
1147
|
+
* @return [String] host with port
|
1148
|
+
*/
|
1149
|
+
/* rb_define_attr(cb_cBucket, "authority", 1, 0); */
|
1150
|
+
rb_define_method(cb_cBucket, "authority", cb_bucket_authority_get, 0);
|
1151
|
+
/* Document-method: bucket
|
1152
|
+
*
|
1153
|
+
* The bucket name of the current connection
|
1154
|
+
*
|
1155
|
+
* @see Bucket#url
|
1156
|
+
*
|
1157
|
+
* @since 1.0.0
|
1158
|
+
*
|
1159
|
+
* @return [String] the bucket name
|
1160
|
+
*/
|
1161
|
+
/* rb_define_attr(cb_cBucket, "bucket", 1, 0); */
|
1162
|
+
rb_define_method(cb_cBucket, "bucket", cb_bucket_bucket_get, 0);
|
1163
|
+
rb_define_alias(cb_cBucket, "name", "bucket");
|
1164
|
+
/* Document-method: pool
|
1165
|
+
*
|
1166
|
+
* The pool name of the current connection
|
1167
|
+
*
|
1168
|
+
* @see Bucket#url
|
1169
|
+
*
|
1170
|
+
* @since 1.0.0
|
1171
|
+
*
|
1172
|
+
* @return [String] the pool name (usually "default")
|
1173
|
+
*/
|
1174
|
+
/* rb_define_attr(cb_cBucket, "pool", 1, 0); */
|
1175
|
+
rb_define_method(cb_cBucket, "pool", cb_bucket_pool_get, 0);
|
1176
|
+
/* Document-method: username
|
1177
|
+
*
|
1178
|
+
* The user name used to connect to the cluster
|
1179
|
+
*
|
1180
|
+
* @see Bucket#url
|
1181
|
+
*
|
1182
|
+
* @since 1.0.0
|
1183
|
+
*
|
1184
|
+
* @return [String] the username for protected buckets (usually matches
|
1185
|
+
* the bucket name)
|
1186
|
+
*/
|
1187
|
+
/* rb_define_attr(cb_cBucket, "username", 1, 0); */
|
1188
|
+
rb_define_method(cb_cBucket, "username", cb_bucket_username_get, 0);
|
1189
|
+
/* Document-method: password
|
1190
|
+
*
|
1191
|
+
* The password used to connect to the cluster
|
1192
|
+
*
|
1193
|
+
* @since 1.0.0
|
1194
|
+
*
|
1195
|
+
* @return [String] the password for protected buckets
|
1196
|
+
*/
|
1197
|
+
/* rb_define_attr(cb_cBucket, "password", 1, 0); */
|
1198
|
+
rb_define_method(cb_cBucket, "password", cb_bucket_password_get, 0);
|
1199
|
+
/* Document-method: environment
|
1200
|
+
*
|
1201
|
+
* The environment of the connection (+:development+ or +:production+)
|
1202
|
+
*
|
1203
|
+
* @since 1.2.0
|
1204
|
+
*
|
1205
|
+
* @return [Symbol]
|
1206
|
+
*/
|
1207
|
+
/* rb_define_attr(cb_cBucket, "environment", 1, 0); */
|
1208
|
+
rb_define_method(cb_cBucket, "environment", cb_bucket_environment_get, 0);
|
1209
|
+
/* Document-method: num_replicas
|
1210
|
+
*
|
1211
|
+
* @since 1.2.0.dp6
|
1212
|
+
*
|
1213
|
+
* The numbers of the replicas for each node in the cluster
|
1214
|
+
*
|
1215
|
+
* @return [Fixnum]
|
1216
|
+
*/
|
1217
|
+
/* rb_define_attr(cb_cBucket, "num_replicas", 1, 0); */
|
1218
|
+
rb_define_method(cb_cBucket, "num_replicas", cb_bucket_num_replicas_get, 0);
|
1219
|
+
/* Document-method: default_observe_timeout
|
1220
|
+
*
|
1221
|
+
* @since 1.2.0.dp6
|
1222
|
+
*
|
1223
|
+
* The default timeout value for {Bucket#observe_and_wait} operation in
|
1224
|
+
* microseconds
|
1225
|
+
*
|
1226
|
+
* @return [Fixnum]
|
1227
|
+
*/
|
1228
|
+
/* rb_define_attr(cb_cBucket, "default_observe_timeout", 1, 1); */
|
1229
|
+
rb_define_method(cb_cBucket, "default_observe_timeout", cb_bucket_default_observe_timeout_get, 0);
|
1230
|
+
rb_define_method(cb_cBucket, "default_observe_timeout=", cb_bucket_default_observe_timeout_set, 1);
|
1231
|
+
|
1232
|
+
cb_cCouchRequest = rb_define_class_under(cb_cBucket, "CouchRequest", rb_cObject);
|
1233
|
+
rb_define_alloc_func(cb_cCouchRequest, cb_http_request_alloc);
|
1234
|
+
|
1235
|
+
rb_define_method(cb_cCouchRequest, "initialize", cb_http_request_init, -1);
|
1236
|
+
rb_define_method(cb_cCouchRequest, "inspect", cb_http_request_inspect, 0);
|
1237
|
+
rb_define_method(cb_cCouchRequest, "on_body", cb_http_request_on_body, 0);
|
1238
|
+
rb_define_method(cb_cCouchRequest, "perform", cb_http_request_perform, 0);
|
1239
|
+
rb_define_method(cb_cCouchRequest, "pause", cb_http_request_pause, 0);
|
1240
|
+
rb_define_method(cb_cCouchRequest, "continue", cb_http_request_continue, 0);
|
1241
|
+
|
1242
|
+
/* rb_define_attr(cb_cCouchRequest, "path", 1, 0); */
|
1243
|
+
rb_define_method(cb_cCouchRequest, "path", cb_http_request_path_get, 0);
|
1244
|
+
/* rb_define_attr(cb_cCouchRequest, "extended", 1, 0); */
|
1245
|
+
rb_define_method(cb_cCouchRequest, "extended", cb_http_request_extended_get, 0);
|
1246
|
+
rb_define_alias(cb_cCouchRequest, "extended?", "extended");
|
1247
|
+
/* rb_define_attr(cb_cCouchRequest, "chunked", 1, 0); */
|
1248
|
+
rb_define_method(cb_cCouchRequest, "chunked", cb_http_request_chunked_get, 0);
|
1249
|
+
rb_define_alias(cb_cCouchRequest, "chunked?", "chunked");
|
1250
|
+
|
1251
|
+
cb_cTimer = rb_define_class_under(cb_mCouchbase, "Timer", rb_cObject);
|
1252
|
+
rb_define_alloc_func(cb_cTimer, cb_timer_alloc);
|
1253
|
+
rb_define_method(cb_cTimer, "initialize", cb_timer_init, -1);
|
1254
|
+
rb_define_method(cb_cTimer, "inspect", cb_timer_inspect, 0);
|
1255
|
+
rb_define_method(cb_cTimer, "cancel", cb_timer_cancel, 0);
|
1256
|
+
|
1257
|
+
/* Define cb_symbols */
|
1258
|
+
cb_id_add_shutdown_hook = rb_intern("add_shutdown_hook");
|
1259
|
+
cb_id_arity = rb_intern("arity");
|
1260
|
+
cb_id_call = rb_intern("call");
|
1261
|
+
cb_id_create_timer = rb_intern("create_timer");
|
1262
|
+
cb_id_delete = rb_intern("delete");
|
1263
|
+
cb_id_dump = rb_intern("dump");
|
1264
|
+
cb_id_dup = rb_intern("dup");
|
1265
|
+
cb_id_flatten_bang = rb_intern("flatten!");
|
1266
|
+
cb_id_has_key_p = rb_intern("has_key?");
|
1267
|
+
cb_id_host = rb_intern("host");
|
1268
|
+
cb_id_load = rb_intern("load");
|
1269
|
+
cb_id_match = rb_intern("match");
|
1270
|
+
cb_id_next_tick = rb_intern("next_tick");
|
1271
|
+
cb_id_observe_and_wait = rb_intern("observe_and_wait");
|
1272
|
+
cb_id_parse = rb_intern("parse");
|
1273
|
+
cb_id_parse_body_bang = rb_intern("parse_body!");
|
1274
|
+
cb_id_password = rb_intern("password");
|
1275
|
+
cb_id_path = rb_intern("path");
|
1276
|
+
cb_id_port = rb_intern("port");
|
1277
|
+
cb_id_scheme = rb_intern("scheme");
|
1278
|
+
cb_id_sprintf = rb_intern("sprintf");
|
1279
|
+
cb_id_to_s = rb_intern("to_s");
|
1280
|
+
cb_id_user = rb_intern("user");
|
1281
|
+
cb_id_verify_observe_options = rb_intern("verify_observe_options");
|
1282
|
+
|
1283
|
+
cb_sym_add = ID2SYM(rb_intern("add"));
|
1284
|
+
cb_sym_all = ID2SYM(rb_intern("all"));
|
1285
|
+
cb_sym_append = ID2SYM(rb_intern("append"));
|
1286
|
+
cb_sym_assemble_hash = ID2SYM(rb_intern("assemble_hash"));
|
1287
|
+
cb_sym_async = ID2SYM(rb_intern("async"));
|
1288
|
+
cb_sym_body = ID2SYM(rb_intern("body"));
|
1289
|
+
cb_sym_bucket = ID2SYM(rb_intern("bucket"));
|
1290
|
+
cb_sym_cas = ID2SYM(rb_intern("cas"));
|
1291
|
+
cb_sym_chunked = ID2SYM(rb_intern("chunked"));
|
1292
|
+
cb_sym_cluster = ID2SYM(rb_intern("cluster"));
|
1293
|
+
cb_sym_connect = ID2SYM(rb_intern("connect"));
|
1294
|
+
cb_sym_content_type = ID2SYM(rb_intern("content_type"));
|
1295
|
+
cb_sym_create = ID2SYM(rb_intern("create"));
|
1296
|
+
cb_sym_decrement = ID2SYM(rb_intern("decrement"));
|
1297
|
+
cb_sym_default = ID2SYM(rb_intern("default"));
|
1298
|
+
cb_sym_default_arithmetic_init = ID2SYM(rb_intern("default_arithmetic_init"));
|
1299
|
+
cb_sym_default_flags = ID2SYM(rb_intern("default_flags"));
|
1300
|
+
cb_sym_default_format = ID2SYM(rb_intern("default_format"));
|
1301
|
+
cb_sym_default_ttl = ID2SYM(rb_intern("default_ttl"));
|
1302
|
+
cb_sym_delete = ID2SYM(rb_intern("delete"));
|
1303
|
+
cb_sym_delta = ID2SYM(rb_intern("delta"));
|
1304
|
+
cb_sym_development = ID2SYM(rb_intern("development"));
|
1305
|
+
cb_sym_document = ID2SYM(rb_intern("document"));
|
1306
|
+
cb_sym_engine = ID2SYM(rb_intern("engine"));
|
1307
|
+
cb_sym_environment = ID2SYM(rb_intern("environment"));
|
1308
|
+
cb_sym_eventmachine = ID2SYM(rb_intern("eventmachine"));
|
1309
|
+
cb_sym_extended = ID2SYM(rb_intern("extended"));
|
1310
|
+
cb_sym_first = ID2SYM(rb_intern("first"));
|
1311
|
+
cb_sym_flags = ID2SYM(rb_intern("flags"));
|
1312
|
+
cb_sym_forced = ID2SYM(rb_intern("forced"));
|
1313
|
+
cb_sym_format = ID2SYM(rb_intern("format"));
|
1314
|
+
cb_sym_found = ID2SYM(rb_intern("found"));
|
1315
|
+
cb_sym_get = ID2SYM(rb_intern("get"));
|
1316
|
+
cb_sym_hostname = ID2SYM(rb_intern("hostname"));
|
1317
|
+
cb_sym_http_request = ID2SYM(rb_intern("http_request"));
|
1318
|
+
cb_sym_increment = ID2SYM(rb_intern("increment"));
|
1319
|
+
cb_sym_initial = ID2SYM(rb_intern("initial"));
|
1320
|
+
cb_sym_iocp = ID2SYM(rb_intern("iocp"));
|
1321
|
+
cb_sym_key_prefix = ID2SYM(rb_intern("key_prefix"));
|
1322
|
+
cb_sym_libev = ID2SYM(rb_intern("libev"));
|
1323
|
+
cb_sym_libevent = ID2SYM(rb_intern("libevent"));
|
1324
|
+
cb_sym_lock = ID2SYM(rb_intern("lock"));
|
1325
|
+
cb_sym_management = ID2SYM(rb_intern("management"));
|
1326
|
+
cb_sym_marshal = ID2SYM(rb_intern("marshal"));
|
1327
|
+
cb_sym_method = ID2SYM(rb_intern("method"));
|
1328
|
+
cb_sym_node_list = ID2SYM(rb_intern("node_list"));
|
1329
|
+
cb_sym_not_found = ID2SYM(rb_intern("not_found"));
|
1330
|
+
cb_sym_num_replicas = ID2SYM(rb_intern("num_replicas"));
|
1331
|
+
cb_sym_observe = ID2SYM(rb_intern("observe"));
|
1332
|
+
cb_sym_password = ID2SYM(rb_intern("password"));
|
1333
|
+
cb_sym_periodic = ID2SYM(rb_intern("periodic"));
|
1334
|
+
cb_sym_persisted = ID2SYM(rb_intern("persisted"));
|
1335
|
+
cb_sym_plain = ID2SYM(rb_intern("plain"));
|
1336
|
+
cb_sym_pool = ID2SYM(rb_intern("pool"));
|
1337
|
+
cb_sym_port = ID2SYM(rb_intern("port"));
|
1338
|
+
cb_sym_post = ID2SYM(rb_intern("post"));
|
1339
|
+
cb_sym_prepend = ID2SYM(rb_intern("prepend"));
|
1340
|
+
cb_sym_production = ID2SYM(rb_intern("production"));
|
1341
|
+
cb_sym_put = ID2SYM(rb_intern("put"));
|
1342
|
+
cb_sym_quiet = ID2SYM(rb_intern("quiet"));
|
1343
|
+
cb_sym_replace = ID2SYM(rb_intern("replace"));
|
1344
|
+
cb_sym_replica = ID2SYM(rb_intern("replica"));
|
1345
|
+
cb_sym_select = ID2SYM(rb_intern("select"));
|
1346
|
+
cb_sym_send_threshold = ID2SYM(rb_intern("send_threshold"));
|
1347
|
+
cb_sym_set = ID2SYM(rb_intern("set"));
|
1348
|
+
cb_sym_stats = ID2SYM(rb_intern("stats"));
|
1349
|
+
cb_sym_timeout = ID2SYM(rb_intern("timeout"));
|
1350
|
+
cb_sym_touch = ID2SYM(rb_intern("touch"));
|
1351
|
+
cb_sym_transcoder = ID2SYM(rb_intern("transcoder"));
|
1352
|
+
cb_sym_ttl = ID2SYM(rb_intern("ttl"));
|
1353
|
+
cb_sym_type = ID2SYM(rb_intern("type"));
|
1354
|
+
cb_sym_unlock = ID2SYM(rb_intern("unlock"));
|
1355
|
+
cb_sym_username = ID2SYM(rb_intern("username"));
|
1356
|
+
cb_sym_version = ID2SYM(rb_intern("version"));
|
1357
|
+
cb_sym_view = ID2SYM(rb_intern("view"));
|
1358
|
+
|
1359
|
+
interned = rb_ary_new();
|
1360
|
+
rb_const_set(cb_mCouchbase, rb_intern("_INTERNED"), interned);
|
1361
|
+
cb_vStrDefault = cb_intern_string(interned, "default");
|
1362
|
+
cb_vStrEmpty = cb_intern_string(interned, "");
|
1363
|
+
cb_vStrLocalhost = cb_intern_string(interned, "localhost");
|
1364
|
+
}
|