pools 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cassandra/pooled.rb +32 -0
- data/lib/pools/connection_pool.rb +1 -0
- data/lib/pools/pooled.rb +16 -3
- data/lib/redis/pooled.rb +1 -0
- metadata +50 -33
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pools'
|
2
|
+
require 'cassandra/0.7'
|
3
|
+
|
4
|
+
class Cassandra
|
5
|
+
class Pooled
|
6
|
+
include ::Pools::Pooled
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
@cassandra_args = args.dup
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def __connection
|
14
|
+
Cassandra.new(*@cassandra_args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def __disconnect(client)
|
18
|
+
client.disconnect! if client
|
19
|
+
end
|
20
|
+
|
21
|
+
preparation_methods :login!, :disable_node_auto_discovery!
|
22
|
+
|
23
|
+
connection_methods :keyspace, :keyspaces, :servers, :schema,
|
24
|
+
:auth_request, :thrift_client_options, :thrift_client_class,
|
25
|
+
:insert, :remove, :count_columns, :multi_count_columns,
|
26
|
+
:get_columns, :multi_get_columns, :get, :multi_get, :exists?,
|
27
|
+
:get_range, :count_range, :batch, :schema_agreement?, :version,
|
28
|
+
:cluster_name, :ring, :partitioner, :truncate!, :clear_keyspace!,
|
29
|
+
:add_column_family, :drop_column_family, :rename_column_family,
|
30
|
+
:add_keyspace, :drop_keyspace, :rename_keyspace
|
31
|
+
end
|
32
|
+
end
|
data/lib/pools/pooled.rb
CHANGED
@@ -4,10 +4,11 @@ require 'active_support/concern'
|
|
4
4
|
module Pools
|
5
5
|
module Pooled
|
6
6
|
extend ActiveSupport::Concern
|
7
|
-
attr_reader :connection_pool
|
7
|
+
attr_reader :connection_pool, :preparation_chain
|
8
8
|
|
9
9
|
def initialize(*args)
|
10
10
|
options = args.extract_options!
|
11
|
+
@preparation_chain = []
|
11
12
|
@connection_pool = ConnectionPool.new(self, options)
|
12
13
|
Pools.handler.add(@connection_pool, options[:pool_name])
|
13
14
|
end
|
@@ -24,16 +25,28 @@ module Pools
|
|
24
25
|
# Override in parent
|
25
26
|
end
|
26
27
|
|
28
|
+
def __prepare(connection)
|
29
|
+
@preparation_chain.each { |args| connection.send(*args) }
|
30
|
+
end
|
31
|
+
|
27
32
|
module ClassMethods
|
28
33
|
def connection_methods(*methods)
|
29
34
|
methods.each do |method|
|
30
|
-
define_method(method) do |*params|
|
35
|
+
define_method(method) do |*params, &block|
|
31
36
|
with_connection do |client|
|
32
|
-
client.send(method, *params)
|
37
|
+
client.send(method, *params, &block)
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
42
|
+
|
43
|
+
def preparation_methods(*methods)
|
44
|
+
methods.each do |method|
|
45
|
+
define_method(method) do |*params|
|
46
|
+
@preparation_chain << ([method] + params)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
37
50
|
end
|
38
51
|
end
|
39
52
|
end
|
data/lib/redis/pooled.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
|
-
|
13
|
+
- Michael Rykov
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-05-22 00:00:00 -07:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: activesupport
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 0
|
33
|
+
- 5
|
34
|
+
version: 3.0.5
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
27
37
|
description: |
|
28
38
|
Generalized connection pooling
|
29
39
|
|
@@ -35,17 +45,18 @@ extensions: []
|
|
35
45
|
extra_rdoc_files: []
|
36
46
|
|
37
47
|
files:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- LICENSE
|
51
|
+
- lib/cassandra/pooled.rb
|
52
|
+
- lib/pools/connection_pool.rb
|
53
|
+
- lib/pools/handler.rb
|
54
|
+
- lib/pools/middleware.rb
|
55
|
+
- lib/pools/pooled.rb
|
56
|
+
- lib/pools.rb
|
57
|
+
- lib/redis/pooled.rb
|
58
|
+
- lib/redis/pooled_store.rb
|
59
|
+
has_rdoc: false
|
49
60
|
homepage: http://github.com/rykov/pools
|
50
61
|
licenses: []
|
51
62
|
|
@@ -53,23 +64,29 @@ post_install_message:
|
|
53
64
|
rdoc_options: []
|
54
65
|
|
55
66
|
require_paths:
|
56
|
-
|
67
|
+
- lib
|
57
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
69
|
none: false
|
59
70
|
requirements:
|
60
|
-
|
61
|
-
|
62
|
-
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
63
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
78
|
none: false
|
65
79
|
requirements:
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
69
86
|
requirements: []
|
70
87
|
|
71
88
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.
|
89
|
+
rubygems_version: 1.6.2
|
73
90
|
signing_key:
|
74
91
|
specification_version: 3
|
75
92
|
summary: Generalized connection pooling
|