sessionm-cassandra_object 2.2.48 → 2.2.49

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,54 +1,65 @@
1
- module CassandraObject
2
- module AsyncConnection
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- class_attribute :connection_spec
1
+ begin
2
+ require 'em-synchrony'
7
3
 
8
- class_eval do
9
- @@fiber_connections = {}
10
- def self.connection()
11
- @@fiber_connections[Fiber.current.object_id] ||=
12
- begin
13
- spec = connection_spec.dup
14
-
15
- if EM.reactor_running?
16
- require 'thrift_client/event_machine'
17
- spec[:thrift].merge!(:transport => Thrift::EventMachineTransport,
18
- :transport_wrapper => nil)
4
+ module CassandraObject
5
+ module AsyncConnection
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ class_attribute :connection_spec
10
+
11
+ class_eval do
12
+ def self.connection()
13
+ @@connection ||=
14
+ begin
15
+ spec = connection_spec.dup
16
+
17
+ if EM.reactor_running?
18
+ require 'thrift_client/event_machine'
19
+ spec[:thrift].merge!(:transport => Thrift::EventMachineTransport,
20
+ :transport_wrapper => nil)
21
+ end
22
+
23
+ EventMachine::Synchrony::ConnectionPool.new(:size => spec[:pool_size] || 5) do
24
+ Cassandra.new(spec[:keyspace], spec[:servers], spec[:thrift].dup)
25
+ end.tap do |pool|
26
+ class << pool
27
+ def method_missing(method, *args, &blk)
28
+ execute(false) do |conn|
29
+ conn.send(method, *args, &blk)
30
+ end
31
+ end
32
+ end
33
+ end
19
34
  end
20
-
21
- Cassandra.new(spec[:keyspace], spec[:servers], spec[:thrift])
22
- end
23
- end
24
- def self.connection?() !!connection end
35
+ end
36
+ def self.connection?() !!connection end
25
37
 
26
- def self.disconnect!
27
- @@fiber_connections.delete(Fiber.current.object_id).tap { |conn|
28
- conn.disconnect! if conn
29
- }
30
- end
38
+ def self.disconnect!; end
31
39
 
32
- def connection
33
- defined?(@connection) ? @connection : singleton_class.connection
34
- end
40
+ def connection
41
+ singleton_class.connection
42
+ end
35
43
 
36
- def connection?
37
- !!connection
44
+ def connection?
45
+ !!connection
46
+ end
38
47
  end
39
48
  end
40
- end
41
49
 
42
- module ClassMethods
43
- DEFAULT_OPTIONS = {
44
- servers: "127.0.0.1:9160",
45
- thrift: {}
46
- }
47
- def establish_connection(spec)
48
- spec.reverse_merge!(DEFAULT_OPTIONS)
49
- spec[:thrift].symbolize_keys!
50
- self.connection_spec = spec
50
+ module ClassMethods
51
+ DEFAULT_OPTIONS = {
52
+ servers: "127.0.0.1:9160",
53
+ thrift: {}
54
+ }
55
+ def establish_connection(spec)
56
+ spec.reverse_merge!(DEFAULT_OPTIONS)
57
+ spec[:thrift].symbolize_keys!
58
+ self.connection_spec = spec
59
+ end
51
60
  end
52
61
  end
53
62
  end
63
+ rescue LoadError
64
+ puts "Could not define alternate em-synchrony cassandra connection" if defined?($TESTING) && $TESTING
54
65
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sessionm-cassandra_object'
5
- s.version = '2.2.48'
5
+ s.version = '2.2.49'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sessionm-cassandra_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.48
4
+ version: 2.2.49
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-04-24 00:00:00.000000000 Z
14
+ date: 2012-05-18 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: !ruby/object:Gem::Requirement
18
+ requirement: &70221054696540 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,15 +23,10 @@ dependencies:
23
23
  version: 3.0.9
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ~>
30
- - !ruby/object:Gem::Version
31
- version: 3.0.9
26
+ version_requirements: *70221054696540
32
27
  - !ruby/object:Gem::Dependency
33
28
  name: cassandra
34
- requirement: !ruby/object:Gem::Requirement
29
+ requirement: &70221054696080 !ruby/object:Gem::Requirement
35
30
  none: false
36
31
  requirements:
37
32
  - - ! '>='
@@ -39,15 +34,10 @@ dependencies:
39
34
  version: 0.11.3
40
35
  type: :runtime
41
36
  prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: 0.11.3
37
+ version_requirements: *70221054696080
48
38
  - !ruby/object:Gem::Dependency
49
39
  name: bundler
50
- requirement: !ruby/object:Gem::Requirement
40
+ requirement: &70221054695620 !ruby/object:Gem::Requirement
51
41
  none: false
52
42
  requirements:
53
43
  - - ! '>='
@@ -55,12 +45,7 @@ dependencies:
55
45
  version: 1.0.0
56
46
  type: :development
57
47
  prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: 1.0.0
48
+ version_requirements: *70221054695620
64
49
  description: Cassandra ActiveModel
65
50
  email: klange@sessionm.com
66
51
  executables: []
@@ -176,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
161
  version: 1.3.5
177
162
  requirements: []
178
163
  rubyforge_project:
179
- rubygems_version: 1.8.22
164
+ rubygems_version: 1.8.15
180
165
  signing_key:
181
166
  specification_version: 3
182
167
  summary: Cassandra ActiveModel