sessionm-cassandra_object 2.4.6 → 2.4.7

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.
@@ -7,31 +7,72 @@ module CassandraObject
7
7
 
8
8
  class_eval do
9
9
  @@fiber_connections = {}
10
+ def self.fiber_connections
11
+ @@fiber_connections
12
+ end
13
+
14
+ def fiber_connections
15
+ self.class.fiber_connections
16
+ end
17
+
18
+ def self.new_event_machine_connection
19
+ spec = connection_spec.dup
20
+
21
+ require 'thrift_client/event_machine'
22
+ spec[:thrift].merge!(:transport => Thrift::EventMachineTransport,
23
+ :transport_wrapper => nil)
24
+
25
+ Cassandra.new(spec[:keyspace], spec[:servers], spec[:thrift]).tap do |conn|
26
+ conn.disable_node_auto_discovery! if spec[:disable_node_auto_discovery]
27
+ if spec[:cache_schema]
28
+ if @@schema
29
+ conn.instance_variable_set '@schema', @@schema
30
+ else
31
+ begin
32
+ @@schema = conn.schema
33
+ rescue CassandraThrift::InvalidRequestException => e
34
+ # initially the schema doesn't exists
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def new_event_machine_connection
42
+ self.class.new_event_machine_connection
43
+ end
44
+
45
+ def self.new_connection
46
+ spec = connection_spec.dup
47
+
48
+ Cassandra.new(spec[:keyspace], spec[:servers], spec[:thrift]).tap do |conn|
49
+ conn.disable_node_auto_discovery! if spec[:disable_node_auto_discovery]
50
+ if spec[:cache_schema]
51
+ if @@schema
52
+ conn.instance_variable_set '@schema', @@schema
53
+ else
54
+ begin
55
+ @@schema = conn.schema
56
+ rescue CassandraThrift::InvalidRequestException => e
57
+ # initially the schema doesn't exists
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def new_connection
65
+ self.class.new_connection
66
+ end
67
+
10
68
  @@schema = nil
11
69
  def self.connection()
12
70
  @@fiber_connections[Fiber.current.object_id] ||=
13
71
  begin
14
- spec = connection_spec.dup
15
-
16
72
  if const_defined?(:EM) && EM.reactor_running?
17
- require 'thrift_client/event_machine'
18
- spec[:thrift].merge!(:transport => Thrift::EventMachineTransport,
19
- :transport_wrapper => nil)
20
- end
21
-
22
- Cassandra.new(spec[:keyspace], spec[:servers], spec[:thrift]).tap do |conn|
23
- conn.disable_node_auto_discovery! if spec[:disable_node_auto_discovery]
24
- if spec[:cache_schema]
25
- if @@schema
26
- conn.instance_variable_set '@schema', @@schema
27
- else
28
- begin
29
- @@schema = conn.schema
30
- rescue CassandraThrift::InvalidRequestException => e
31
- # initially the schema doesn't exists
32
- end
33
- end
34
- end
73
+ new_event_machine_connection
74
+ else
75
+ new_connection
35
76
  end
36
77
  end
37
78
  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.4.6'
5
+ s.version = '2.4.7'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 4
8
- - 6
9
- version: 2.4.6
8
+ - 7
9
+ version: 2.4.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Koziarski
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-05-24 00:00:00 -04:00
19
+ date: 2013-06-03 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency