couchbase 1.1.3-x86-mingw32 → 1.1.4-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.1.4 / 2012-08-30
2
+
3
+ * RCBC-70 return binary keys using Encoding.external value (thanks to Alex Leverington)
4
+ * Switch to rbenv because RVM doesn't work with tclsh
5
+ * [backport] RCBC-37 Bootstrapping using multiple nodes
6
+
1
7
  ## 1.1.3 / 2012-07-27
2
8
 
3
9
  * RCBC-59 Replicate flags in Bucket#cas operation
@@ -24,6 +24,15 @@
24
24
  #include <libcouchbase/couchbase.h>
25
25
  #include "couchbase_config.h"
26
26
 
27
+ #ifdef HAVE_RUBY_ENCODING_H
28
+ #include "ruby/encoding.h"
29
+ #define STR_NEW(ptr, len) rb_external_str_new((ptr), (len))
30
+ #define STR_NEW_CSTR(str) rb_external_str_new_cstr((str))
31
+ #else
32
+ #define STR_NEW(ptr, len) rb_str_new((ptr), (len))
33
+ #define STR_NEW_CSTR(str) rb_str_new2((str))
34
+ #endif
35
+
27
36
  #ifdef HAVE_STDARG_PROTOTYPES
28
37
  #include <stdarg.h>
29
38
  #define va_init_list(a,b) va_start(a,b)
@@ -34,9 +43,9 @@
34
43
 
35
44
  #define debug_object(OBJ) \
36
45
  rb_funcall(rb_stderr, rb_intern("print"), 1, rb_funcall(OBJ, rb_intern("object_id"), 0)); \
37
- rb_funcall(rb_stderr, rb_intern("print"), 1, rb_str_new2(" ")); \
46
+ rb_funcall(rb_stderr, rb_intern("print"), 1, STR_NEW_CSTR(" ")); \
38
47
  rb_funcall(rb_stderr, rb_intern("print"), 1, rb_funcall(OBJ, rb_intern("class"), 0)); \
39
- rb_funcall(rb_stderr, rb_intern("print"), 1, rb_str_new2(" ")); \
48
+ rb_funcall(rb_stderr, rb_intern("print"), 1, STR_NEW_CSTR(" ")); \
40
49
  rb_funcall(rb_stderr, rb_intern("puts"), 1, rb_funcall(OBJ, rb_intern("inspect"), 0));
41
50
 
42
51
  #define FMT_MASK 0x3
@@ -65,6 +74,7 @@ typedef struct
65
74
  VALUE exception; /* error delivered by error_callback */
66
75
  VALUE on_error_proc; /* is using to deliver errors in async mode */
67
76
  VALUE object_space;
77
+ char *node_list;
68
78
  } bucket_t;
69
79
 
70
80
  typedef struct
@@ -115,6 +125,7 @@ static ID sym_add,
115
125
  sym_increment,
116
126
  sym_initial,
117
127
  sym_marshal,
128
+ sym_node_list,
118
129
  sym_password,
119
130
  sym_plain,
120
131
  sym_pool,
@@ -455,7 +466,7 @@ unify_key(VALUE key)
455
466
  case T_STRING:
456
467
  return key;
457
468
  case T_SYMBOL:
458
- return rb_str_new2(rb_id2name(SYM2ID(key)));
469
+ return STR_NEW_CSTR(rb_id2name(SYM2ID(key)));
459
470
  default: /* call #to_str or raise error */
460
471
  return StringValue(key);
461
472
  }
@@ -563,7 +574,7 @@ storage_callback(libcouchbase_t handle, const void *cookie,
563
574
 
564
575
  bucket->seqno--;
565
576
 
566
- k = rb_str_new((const char*)key, nkey);
577
+ k = STR_NEW((const char*)key, nkey);
567
578
  c = cas > 0 ? ULL2NUM(cas) : Qnil;
568
579
  switch(operation) {
569
580
  case LIBCOUCHBASE_ADD:
@@ -624,7 +635,7 @@ delete_callback(libcouchbase_t handle, const void *cookie,
624
635
 
625
636
  bucket->seqno--;
626
637
 
627
- k = rb_str_new((const char*)key, nkey);
638
+ k = STR_NEW((const char*)key, nkey);
628
639
  if (error != LIBCOUCHBASE_KEY_ENOENT || !ctx->quiet) {
629
640
  exc = cb_check_error(error, "failed to remove value", k);
630
641
  if (exc != Qnil) {
@@ -666,7 +677,7 @@ get_callback(libcouchbase_t handle, const void *cookie,
666
677
 
667
678
  bucket->seqno--;
668
679
 
669
- k = rb_str_new((const char*)key, nkey);
680
+ k = STR_NEW((const char*)key, nkey);
670
681
  if (error != LIBCOUCHBASE_KEY_ENOENT || !ctx->quiet) {
671
682
  exc = cb_check_error(error, "failed to get value", k);
672
683
  if (exc != Qnil) {
@@ -682,7 +693,7 @@ get_callback(libcouchbase_t handle, const void *cookie,
682
693
  c = ULL2NUM(cas);
683
694
  v = Qnil;
684
695
  if (nbytes != 0) {
685
- v = decode_value(rb_str_new((const char*)bytes, nbytes), flags, ctx->force_format);
696
+ v = decode_value(STR_NEW((const char*)bytes, nbytes), flags, ctx->force_format);
686
697
  if (v == Qundef) {
687
698
  if (ctx->exception != Qnil) {
688
699
  cb_gc_unprotect(bucket, ctx->exception);
@@ -693,7 +704,7 @@ get_callback(libcouchbase_t handle, const void *cookie,
693
704
  cb_gc_protect(bucket, ctx->exception);
694
705
  }
695
706
  } else if (flags_get_format(flags) == sym_plain) {
696
- v = rb_str_new2("");
707
+ v = STR_NEW_CSTR("");
697
708
  }
698
709
  if (bucket->async) { /* asynchronous */
699
710
  if (ctx->proc != Qnil) {
@@ -731,7 +742,7 @@ flush_callback(libcouchbase_t handle, const void* cookie,
731
742
  bucket_t *bucket = ctx->bucket;
732
743
  VALUE node, success = Qtrue, *rv = ctx->rv, exc, res;
733
744
 
734
- node = authority ? rb_str_new2(authority) : Qnil;
745
+ node = authority ? STR_NEW_CSTR(authority) : Qnil;
735
746
  exc = cb_check_error(error, "failed to flush bucket", node);
736
747
  if (exc != Qnil) {
737
748
  rb_ivar_set(exc, id_iv_operation, sym_flush);
@@ -777,7 +788,7 @@ version_callback(libcouchbase_t handle, const void *cookie,
777
788
  bucket_t *bucket = ctx->bucket;
778
789
  VALUE node, v, *rv = ctx->rv, exc, res;
779
790
 
780
- node = authority ? rb_str_new2(authority) : Qnil;
791
+ node = authority ? STR_NEW_CSTR(authority) : Qnil;
781
792
  exc = cb_check_error(error, "failed to get version", node);
782
793
  if (exc != Qnil) {
783
794
  rb_ivar_set(exc, id_iv_operation, sym_flush);
@@ -788,7 +799,7 @@ version_callback(libcouchbase_t handle, const void *cookie,
788
799
  }
789
800
 
790
801
  if (authority) {
791
- v = rb_str_new((const char*)bytes, nbytes);
802
+ v = STR_NEW((const char*)bytes, nbytes);
792
803
  if (bucket->async) { /* asynchronous */
793
804
  if (ctx->proc != Qnil) {
794
805
  res = rb_class_new_instance(0, NULL, cResult);
@@ -824,7 +835,7 @@ stat_callback(libcouchbase_t handle, const void* cookie,
824
835
  bucket_t *bucket = ctx->bucket;
825
836
  VALUE stats, node, k, v, *rv = ctx->rv, exc = Qnil, res;
826
837
 
827
- node = authority ? rb_str_new2(authority) : Qnil;
838
+ node = authority ? STR_NEW_CSTR(authority) : Qnil;
828
839
  exc = cb_check_error(error, "failed to fetch stats", node);
829
840
  if (exc != Qnil) {
830
841
  rb_ivar_set(exc, id_iv_operation, sym_stats);
@@ -834,8 +845,8 @@ stat_callback(libcouchbase_t handle, const void* cookie,
834
845
  }
835
846
  }
836
847
  if (authority) {
837
- k = rb_str_new((const char*)key, nkey);
838
- v = rb_str_new((const char*)bytes, nbytes);
848
+ k = STR_NEW((const char*)key, nkey);
849
+ v = STR_NEW((const char*)bytes, nbytes);
839
850
  if (bucket->async) { /* asynchronous */
840
851
  if (ctx->proc != Qnil) {
841
852
  res = rb_class_new_instance(0, NULL, cResult);
@@ -876,7 +887,7 @@ touch_callback(libcouchbase_t handle, const void *cookie,
876
887
  VALUE k, success, *rv = ctx->rv, exc = Qnil, res;
877
888
 
878
889
  bucket->seqno--;
879
- k = rb_str_new((const char*)key, nkey);
890
+ k = STR_NEW((const char*)key, nkey);
880
891
  if (error != LIBCOUCHBASE_KEY_ENOENT || !ctx->quiet) {
881
892
  exc = cb_check_error(error, "failed to touch value", k);
882
893
  if (exc != Qnil) {
@@ -922,7 +933,7 @@ arithmetic_callback(libcouchbase_t handle, const void *cookie,
922
933
 
923
934
  bucket->seqno--;
924
935
 
925
- k = rb_str_new((const char*)key, nkey);
936
+ k = STR_NEW((const char*)key, nkey);
926
937
  c = cas > 0 ? ULL2NUM(cas) : Qnil;
927
938
  o = ctx->arithm > 0 ? sym_increment : sym_decrement;
928
939
  exc = cb_check_error(error, "failed to perform arithmetic operation", k);
@@ -1042,7 +1053,7 @@ do_scan_connection_options(bucket_t *bucket, int argc, VALUE *argv)
1042
1053
  uri_obj = rb_funcall(mURI, id_parse, 1, uri);
1043
1054
 
1044
1055
  arg = rb_funcall(uri_obj, id_scheme, 0);
1045
- if (arg == Qnil || rb_str_cmp(arg, rb_str_new2("http"))) {
1056
+ if (arg == Qnil || rb_str_cmp(arg, STR_NEW_CSTR("http"))) {
1046
1057
  rb_raise(rb_eArgError, "invalid URI: invalid scheme");
1047
1058
  }
1048
1059
 
@@ -1088,6 +1099,14 @@ do_scan_connection_options(bucket_t *bucket, int argc, VALUE *argv)
1088
1099
  bucket->bucket = strdup(NIL_P(arg) ? "default" : RSTRING_PTR(arg));
1089
1100
  }
1090
1101
  if (TYPE(opts) == T_HASH) {
1102
+ arg = rb_hash_aref(opts, sym_node_list);
1103
+ if (arg != Qnil) {
1104
+ VALUE tt;
1105
+ free(bucket->node_list);
1106
+ Check_Type(arg, T_ARRAY);
1107
+ tt = rb_ary_join(arg, rb_str_new2(";"));
1108
+ bucket->node_list = strdup(StringValueCStr(tt));
1109
+ }
1091
1110
  arg = rb_hash_aref(opts, sym_hostname);
1092
1111
  if (arg != Qnil) {
1093
1112
  if (bucket->hostname) {
@@ -1191,7 +1210,7 @@ do_connect(bucket_t *bucket)
1191
1210
  if (bucket->io == NULL && err != LIBCOUCHBASE_SUCCESS) {
1192
1211
  rb_exc_raise(cb_check_error(err, "failed to create IO instance", Qnil));
1193
1212
  }
1194
- bucket->handle = libcouchbase_create(bucket->authority,
1213
+ bucket->handle = libcouchbase_create(bucket->node_list ? bucket-> node_list : bucket->authority,
1195
1214
  bucket->username, bucket->password, bucket->bucket, bucket->io);
1196
1215
  if (bucket->handle == NULL) {
1197
1216
  rb_raise(eLibcouchbaseError, "failed to create libcouchbase instance");
@@ -1258,6 +1277,10 @@ cb_bucket_alloc(VALUE klass)
1258
1277
  * Initialize bucket using options only.
1259
1278
  *
1260
1279
  * @param [Hash] options The options for operation for connection
1280
+ * @option options [Array] :node_list (nil) the list of nodes to connect
1281
+ * to. If specified it takes precedence over +:host+ option. The list
1282
+ * must be array of strings in form of host names or host names with
1283
+ * ports (in first case port 8091 will be used, see examples).
1261
1284
  * @option options [String] :host ("localhost") the hostname or IP address
1262
1285
  * of the node
1263
1286
  * @option options [Fixnum] :port (8091) the port of the managemenent API
@@ -1290,6 +1313,9 @@ cb_bucket_alloc(VALUE klass)
1290
1313
  * Couchbase.new('http://localhost:8091/pools/default/buckets/protected',
1291
1314
  * :username => 'protected', :password => 'secret')
1292
1315
  *
1316
+ * @example Use list of nodes, in case some nodes might be dead
1317
+ * Couchbase.new(:node_list => ['example.com:8091', 'example.org:8091', 'example.net'])
1318
+ *
1293
1319
  * @return [Bucket]
1294
1320
  */
1295
1321
  static VALUE
@@ -1310,6 +1336,7 @@ cb_bucket_init(int argc, VALUE *argv, VALUE self)
1310
1336
  bucket->on_error_proc = Qnil;
1311
1337
  bucket->timeout = 0;
1312
1338
  bucket->object_space = rb_hash_new();
1339
+ bucket->node_list = NULL;
1313
1340
 
1314
1341
  do_scan_connection_options(bucket, argc, argv);
1315
1342
  do_connect(bucket);
@@ -1569,7 +1596,7 @@ cb_bucket_hostname_get(VALUE self)
1569
1596
  rb_raise(eNoMemoryError, "failed to allocate memory for Bucket");
1570
1597
  }
1571
1598
  }
1572
- return rb_str_new2(bucket->hostname);
1599
+ return STR_NEW_CSTR(bucket->hostname);
1573
1600
  }
1574
1601
 
1575
1602
  /* Document-method: port
@@ -1602,7 +1629,7 @@ cb_bucket_authority_get(VALUE self)
1602
1629
  rb_raise(eNoMemoryError, "failed to allocate memory for Bucket");
1603
1630
  }
1604
1631
  snprintf(bucket->authority, len, "%s:%u", bucket->hostname, bucket->port);
1605
- return rb_str_new2(bucket->authority);
1632
+ return STR_NEW_CSTR(bucket->authority);
1606
1633
  }
1607
1634
 
1608
1635
  /* Document-method: bucket
@@ -1612,7 +1639,7 @@ cb_bucket_authority_get(VALUE self)
1612
1639
  cb_bucket_bucket_get(VALUE self)
1613
1640
  {
1614
1641
  bucket_t *bucket = DATA_PTR(self);
1615
- return rb_str_new2(bucket->bucket);
1642
+ return STR_NEW_CSTR(bucket->bucket);
1616
1643
  }
1617
1644
 
1618
1645
  /* Document-method: pool
@@ -1622,7 +1649,7 @@ cb_bucket_bucket_get(VALUE self)
1622
1649
  cb_bucket_pool_get(VALUE self)
1623
1650
  {
1624
1651
  bucket_t *bucket = DATA_PTR(self);
1625
- return rb_str_new2(bucket->pool);
1652
+ return STR_NEW_CSTR(bucket->pool);
1626
1653
  }
1627
1654
 
1628
1655
  /* Document-method: username
@@ -1633,7 +1660,7 @@ cb_bucket_pool_get(VALUE self)
1633
1660
  cb_bucket_username_get(VALUE self)
1634
1661
  {
1635
1662
  bucket_t *bucket = DATA_PTR(self);
1636
- return rb_str_new2(bucket->username);
1663
+ return STR_NEW_CSTR(bucket->username);
1637
1664
  }
1638
1665
 
1639
1666
  /* Document-method: password
@@ -1643,7 +1670,7 @@ cb_bucket_username_get(VALUE self)
1643
1670
  cb_bucket_password_get(VALUE self)
1644
1671
  {
1645
1672
  bucket_t *bucket = DATA_PTR(self);
1646
- return rb_str_new2(bucket->password);
1673
+ return STR_NEW_CSTR(bucket->password);
1647
1674
  }
1648
1675
 
1649
1676
  /* Document-method: url
@@ -3549,6 +3576,7 @@ Init_couchbase_ext(void)
3549
3576
  sym_increment = ID2SYM(rb_intern("increment"));
3550
3577
  sym_initial = ID2SYM(rb_intern("initial"));
3551
3578
  sym_marshal = ID2SYM(rb_intern("marshal"));
3579
+ sym_node_list = ID2SYM(rb_intern("node_list"));
3552
3580
  sym_password = ID2SYM(rb_intern("password"));
3553
3581
  sym_plain = ID2SYM(rb_intern("plain"));
3554
3582
  sym_pool = ID2SYM(rb_intern("pool"));
@@ -17,5 +17,5 @@
17
17
 
18
18
  # Couchbase ruby client
19
19
  module Couchbase
20
- VERSION = "1.1.3"
20
+ VERSION = "1.1.4"
21
21
  end
data/tasks/compile.rake CHANGED
@@ -95,7 +95,7 @@ namespace :ports do
95
95
  end
96
96
 
97
97
  task :libcouchbase => [:libvbucket] do
98
- recipe = MiniPortile.new "libcouchbase", "1.0.4"
98
+ recipe = MiniPortile.new "libcouchbase", "1.0.6"
99
99
  recipe.files << "http://packages.couchbase.com/clients/c/#{recipe.name}-#{recipe.version}.tar.gz"
100
100
  recipe.configure_options.push("--disable-debug",
101
101
  "--disable-dependency-tracking",
@@ -118,7 +118,7 @@ task :cross => ["lib/couchbase_ext.rb", "ports:libcouchbase"]
118
118
 
119
119
  desc "Package gem for windows"
120
120
  task "package:windows" => :package do
121
- sh("env RUBY_CC_VERSION=1.8.7 rvm 1.8.7 do bundle exec rake cross compile")
122
- sh("env RUBY_CC_VERSION=1.9.2 rvm 1.9.2 do bundle exec rake cross compile")
123
- sh("env RUBY_CC_VERSION=1.8.7:1.9.2 rvm 1.9.2 do bundle exec rake cross native gem")
121
+ sh("env RUBY_CC_VERSION=1.8.7 RBENV_VERSION=1.8.7-p370 rbenv exec bundle exec rake cross compile")
122
+ sh("env RUBY_CC_VERSION=1.9.2 RBENV_VERSION=1.9.2-p320 rbenv exec bundle exec rake cross compile")
123
+ sh("env RUBY_CC_VERSION=1.8.7:1.9.2 RBENV_VERSION=1.9.2-p320 rbenv exec bundle exec rake cross native gem")
124
124
  end
data/tasks/test.rake CHANGED
@@ -19,7 +19,7 @@ require 'rake/testtask'
19
19
  require 'rake/clean'
20
20
 
21
21
  rule 'test/CouchbaseMock.jar' do |task|
22
- jar_path = "0.5-SNAPSHOT/CouchbaseMock-0.5-20120222.060643-15.jar"
22
+ jar_path = "0.5-SNAPSHOT/CouchbaseMock-0.5-20120726.220757-19.jar"
23
23
  sh %{wget -q -O test/CouchbaseMock.jar http://files.couchbase.com/maven2/org/couchbase/mock/CouchbaseMock/#{jar_path}}
24
24
  end
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: x86-mingw32
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  segments:
202
202
  - 0
203
- hash: 4465124616763901635
203
+ hash: -2223779579395876074
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  none: false
206
206
  requirements:
@@ -209,10 +209,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  segments:
211
211
  - 0
212
- hash: 4465124616763901635
212
+ hash: -2223779579395876074
213
213
  requirements: []
214
214
  rubyforge_project:
215
- rubygems_version: 1.8.24
215
+ rubygems_version: 1.8.23
216
216
  signing_key:
217
217
  specification_version: 3
218
218
  summary: Couchbase ruby driver