slyphon-zookeeper 0.2.7 → 0.2.8

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.
data/Rakefile CHANGED
@@ -1,8 +1,49 @@
1
+ def gemset_name
2
+ ENV.fetch('GEM_HOME').split('@').last
3
+ end
4
+
1
5
  namespace :mb do
2
6
  task :build_gems do
3
- sh "gem build slyphon-zookeeper.gemspec"
7
+ sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
4
8
  ENV['JAVA_GEM'] = '1'
5
- sh "gem build slyphon-zookeeper.gemspec"
9
+ sh "rvm 1.8.7 do gem build slyphon-zookeeper.gemspec"
6
10
  end
7
11
  end
8
12
 
13
+ %w[1.8.7 1.9.2 1.9.3 jruby].each do |rvm_ruby|
14
+ ruby_with_gemset = "#{rvm_ruby}@#{gemset_name}"
15
+
16
+ clobber_task_name = "mb:#{rvm_ruby}:clobber"
17
+ build_task_name = "mb:#{rvm_ruby}:build"
18
+ bundle_task_name = "mb:#{rvm_ruby}:bundle_install"
19
+ rspec_task_name = "mb:#{rvm_ruby}:run_rspec"
20
+
21
+ task clobber_task_name do
22
+ unless rvm_ruby == 'jruby'
23
+ cd 'ext' do
24
+ sh "rake clobber"
25
+ end
26
+ end
27
+ end
28
+
29
+ task build_task_name => clobber_task_name do
30
+ unless rvm_ruby == 'jruby'
31
+ cd 'ext' do
32
+ sh "rvm #{ruby_with_gemset} do rake build"
33
+ end
34
+ end
35
+ end
36
+
37
+ task bundle_task_name => build_task_name do
38
+ rm_f 'Gemfile.lock'
39
+ sh "rvm #{ruby_with_gemset} do bundle install"
40
+ end
41
+
42
+ task rspec_task_name => bundle_task_name do
43
+ sh "rvm #{ruby_with_gemset} do bundle exec rspec spec"
44
+ end
45
+
46
+ task "mb:test_all_rubies" => rspec_task_name
47
+ end
48
+
49
+
data/ext/Rakefile CHANGED
@@ -12,7 +12,7 @@ task :clobber => :clean do
12
12
  end
13
13
 
14
14
  task :build_zkc do
15
- ruby 'extconf.rb'
15
+ sh 'ruby extconf.rb'
16
16
  end
17
17
 
18
18
  file 'Makefile' => :build_zkc
data/ext/extconf.rb CHANGED
@@ -6,8 +6,16 @@ HERE = File.expand_path(File.dirname(__FILE__))
6
6
  BUNDLE = Dir.glob("zkc-*.tar.gz").first
7
7
  BUNDLE_PATH = "c"
8
8
 
9
- $CFLAGS = "#{RbConfig::CONFIG['CFLAGS']} #{$CFLAGS}".gsub("$(cflags)", "").gsub("-arch ppc", "")
10
- $LDFLAGS = "#{RbConfig::CONFIG['LDFLAGS']} #{$LDFLAGS}".gsub("$(ldflags)", "").gsub("-arch ppc", "")
9
+ $EXTRA_CONF = ''
10
+
11
+ # CLANG!!!! jeez, if apple would only *stop* "thinking different"
12
+ if cc = RbConfig::CONFIG['CC'] && cc =~ /^gcc/
13
+ $CC = cc
14
+ $EXTRA_CONF = "#{$EXTRA_CONF} CC=#{$CC}"
15
+ end
16
+
17
+ $CFLAGS = "#{$CFLAGS}".gsub("$(cflags)", "").gsub("-arch ppc", "")
18
+ $LDFLAGS = "#{$LDFLAGS}".gsub("$(ldflags)", "").gsub("-arch ppc", "")
11
19
  $CXXFLAGS = " -std=gnu++98 #{$CFLAGS}"
12
20
  $CPPFLAGS = $ARCH_FLAG = $DLDFLAGS = ""
13
21
 
@@ -16,7 +24,7 @@ DEBUG_CFLAGS = " -O0 -ggdb3 -DHAVE_DEBUG"
16
24
 
17
25
  if ZK_DEBUG
18
26
  $stderr.puts "*** Setting debug flags. ***"
19
- $EXTRA_CONF = " --enable-debug"
27
+ $EXTRA_CONF = "#{$EXTRA_CONF} --enable-debug"
20
28
  $CFLAGS.gsub!(/ -O[^0] /, ' ')
21
29
  $CFLAGS << DEBUG_CFLAGS
22
30
  end
@@ -134,6 +134,14 @@ class ZookeeperBase < CZookeeper
134
134
  super
135
135
  end
136
136
 
137
+ def session_id
138
+ client_id.session_id
139
+ end
140
+
141
+ def session_passwd
142
+ client_id.passwd
143
+ end
144
+
137
145
  protected
138
146
  def barf_unless_running!
139
147
  @start_stop_mutex.synchronize do
data/ext/zookeeper_c.c CHANGED
@@ -25,6 +25,7 @@
25
25
  #include "dbg.h"
26
26
 
27
27
  static VALUE Zookeeper = Qnil;
28
+ static VALUE ZookeeperClientId = Qnil;
28
29
 
29
30
  // slyphon: possibly add a lock to this for synchronizing during get_next_event
30
31
 
@@ -542,12 +543,6 @@ static VALUE method_has_events(VALUE self) {
542
543
  return rb_event;
543
544
  }
544
545
 
545
- static VALUE method_client_id(VALUE self) {
546
- FETCH_DATA_PTR(self, zk);
547
- const clientid_t *id = zoo_client_id(zk->zh);
548
- return UINT2NUM(id->client_id);
549
- }
550
-
551
546
 
552
547
  // wake up the event loop, used when shutting down
553
548
  static VALUE method_wake_event_loop_bang(VALUE self) {
@@ -612,6 +607,29 @@ static VALUE method_recv_timeout(VALUE self) {
612
607
  return INT2NUM(zoo_recv_timeout(zk->zh));
613
608
  }
614
609
 
610
+ /*static VALUE method_client_id(VALUE self) {*/
611
+ /* FETCH_DATA_PTR(self, zk);*/
612
+ /* const clientid_t *id = zoo_client_id(zk->zh);*/
613
+ /* return UINT2NUM(id->client_id);*/
614
+ /*}*/
615
+
616
+
617
+ // returns a CZookeeper::ClientId object with the values set for session_id and passwd
618
+ static VALUE method_client_id(VALUE self) {
619
+ FETCH_DATA_PTR(self, zk);
620
+ const clientid_t *cid = zoo_client_id(zk->zh);
621
+
622
+ VALUE session_id = LL2NUM(cid->client_id);
623
+ VALUE passwd = rb_str_new2(cid->passwd);
624
+
625
+ VALUE client_id_obj = rb_class_new_instance(0, RARRAY_PTR(rb_ary_new()), ZookeeperClientId);
626
+
627
+ rb_funcall(client_id_obj, rb_intern("session_id="), 1, session_id);
628
+ rb_funcall(client_id_obj, rb_intern("passwd="), 1, passwd);
629
+
630
+ return client_id_obj;
631
+ }
632
+
615
633
  static VALUE klass_method_set_debug_level(VALUE klass, VALUE level) {
616
634
  Check_Type(level, T_FIXNUM);
617
635
  ZKRBDebugging = (FIX2INT(level) == ZOO_LOG_LEVEL_DEBUG);
@@ -662,11 +680,31 @@ static void zkrb_define_methods(void) {
662
680
  rb_define_method(Zookeeper, "wake_event_loop!", method_wake_event_loop_bang, 0);
663
681
  }
664
682
 
683
+ // class CZookeeper::ClientId
684
+ // attr_accessor :session_id, :passwd
685
+ //
686
+ // def initialize(session_id, passwd)
687
+ // @session_id = session_id
688
+ // @passwd = passwd
689
+ // end
690
+ // end
691
+
692
+ static VALUE zkrb_client_id_method_initialize(VALUE self) {
693
+ rb_iv_set(self, "@session_id", Qnil);
694
+ rb_iv_set(self, "@passwd", Qnil);
695
+ return Qnil;
696
+ }
697
+
665
698
  void Init_zookeeper_c() {
666
699
  ZKRBDebugging = 0;
667
700
  /* initialize Zookeeper class */
668
701
  Zookeeper = rb_define_class("CZookeeper", rb_cObject);
669
702
  zkrb_define_methods();
703
+
704
+ ZookeeperClientId = rb_define_class_under(Zookeeper, "ClientId", rb_cObject);
705
+ rb_define_method(ZookeeperClientId, "initialize", zkrb_client_id_method_initialize, 0);
706
+ rb_define_attr(ZookeeperClientId, "session_id", 1, 1);
707
+ rb_define_attr(ZookeeperClientId, "passwd", 1, 1);
670
708
  }
671
709
 
672
710
  // vim:ts=2:sw=2:sts=2:et
@@ -475,6 +475,14 @@ class ZookeeperBase
475
475
  @event_queue.clear_reads_on_pop = false
476
476
  @event_queue.selectable_io
477
477
  end
478
+
479
+ def session_id
480
+ @jzk.session_id
481
+ end
482
+
483
+ def session_passwd
484
+ @jzk.session_passwd.to_s
485
+ end
478
486
 
479
487
  def get_next_event(blocking=true)
480
488
  @event_queue.pop(!blocking).tap do |event|
data/lib/zookeeper.rb CHANGED
@@ -200,6 +200,16 @@ class Zookeeper < ZookeeperBase
200
200
  super
201
201
  end
202
202
 
203
+ # return the session id of the current connection as an Fixnum
204
+ def session_id
205
+ super
206
+ end
207
+
208
+ # Return the passwd portion of this connection's credentials as a String
209
+ def session_passwd
210
+ super
211
+ end
212
+
203
213
  protected
204
214
  # used during shutdown, awaken the event delivery thread if it's blocked
205
215
  # waiting for the next event
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "slyphon-zookeeper"
6
- s.version = '0.2.7'
6
+ s.version = '0.2.8'
7
7
 
8
8
  s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Neil Conway", "Jonathan D. Simms"]
9
9
  s.email = ["slyphon@gmail.com"]
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_development_dependency 'flexmock', '~> 0.8.11'
16
16
  s.add_development_dependency 'eventmachine', '1.0.0.beta.4'
17
17
  s.add_development_dependency 'evented-spec', '~> 0.9.0'
18
+ s.add_development_dependency 'rake', '~> 0.9.0'
18
19
 
19
20
  s.files = `git ls-files`.split("\n")
20
21
  s.require_paths = ["lib"]
@@ -951,4 +951,16 @@ describe Zookeeper do
951
951
 
952
952
  end
953
953
  end
954
+
955
+ describe :session_id do
956
+ it %[should return the session_id as a Fixnum] do
957
+ @zk.session_id.should be_kind_of(Fixnum)
958
+ end
959
+ end
960
+
961
+ describe :session_passwd do
962
+ it %[should return the session passwd as a String] do
963
+ @zk.session_passwd.should be_kind_of(String)
964
+ end
965
+ end
954
966
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slyphon-zookeeper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Phillip Pearson
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2011-11-17 00:00:00 Z
23
+ date: 2012-01-27 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
@@ -88,6 +88,22 @@ dependencies:
88
88
  version: 0.9.0
89
89
  type: :development
90
90
  version_requirements: *id004
91
+ - !ruby/object:Gem::Dependency
92
+ name: rake
93
+ prerelease: false
94
+ requirement: &id005 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ hash: 59
100
+ segments:
101
+ - 0
102
+ - 9
103
+ - 0
104
+ version: 0.9.0
105
+ type: :development
106
+ version_requirements: *id005
91
107
  description: twitter's zookeeper client
92
108
  email:
93
109
  - slyphon@gmail.com
@@ -168,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
184
  requirements: []
169
185
 
170
186
  rubyforge_project:
171
- rubygems_version: 1.8.6
187
+ rubygems_version: 1.8.10
172
188
  signing_key:
173
189
  specification_version: 3
174
190
  summary: twitter's zookeeper client