beanpool 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/lib/beanpool/connections.rb +21 -2
- data/lib/beanpool/version.rb +1 -1
- data/lib/beanpool.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5984f05ecf77b56cc3f5ff52d8b5aad0a9f19e77
|
4
|
+
data.tar.gz: 8f9ca1bfbddea6e765bbd0597216f126e7fbca11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 242dcd6d102801b07d0fb6748deb29d21a002cda2d013a6628a4ed0a6c9ea348fe372675e1b26dc7f0c2d557cdbf98057b269aa3d80d4f9e9f85068adccf1859
|
7
|
+
data.tar.gz: 7192ba77d94852bd7c75055491965cfa90da044d19dd0e431f1b67216f3405fde6027b3837a224ed40040e22e3ba4ad1bd80fc9d1816b105803642f1e854961e
|
data/lib/beanpool/connections.rb
CHANGED
@@ -32,7 +32,12 @@ class Beanpool
|
|
32
32
|
def build_connections
|
33
33
|
@ip_array.each do |ip|
|
34
34
|
raise 'Only single IP for beaneater' if ip.is_a?(Array)
|
35
|
-
|
35
|
+
begin
|
36
|
+
@connections[ip] = Beaneater.new(ip)
|
37
|
+
rescue => ex
|
38
|
+
notify(ex)
|
39
|
+
notify("Failed to add #{ip}")
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
@@ -88,7 +93,13 @@ class Beanpool
|
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
91
|
-
def put_job_to_tube(body,
|
96
|
+
def put_job_to_tube(body, options)
|
97
|
+
options = keystring_hash(options)
|
98
|
+
pri = options["pri"] || 32000
|
99
|
+
ttr = options["ttr"] || 60
|
100
|
+
tube_name = options["tube_name"] || 'default'
|
101
|
+
delay = (options["delay"]).to_i
|
102
|
+
|
92
103
|
ip_id = connection_sample
|
93
104
|
connection = @connections[ip_id]
|
94
105
|
begin
|
@@ -102,6 +113,14 @@ class Beanpool
|
|
102
113
|
end
|
103
114
|
end
|
104
115
|
|
116
|
+
def keystring_hash(hash)
|
117
|
+
new_hash = {}
|
118
|
+
hash.keys.each do |k|
|
119
|
+
new_hash[k.to_s] = hash[k]
|
120
|
+
end
|
121
|
+
new_hash
|
122
|
+
end
|
123
|
+
|
105
124
|
def stats(tube_name, stat_name)
|
106
125
|
value = 0
|
107
126
|
@connections.each do |_k, v|
|
data/lib/beanpool/version.rb
CHANGED
data/lib/beanpool.rb
CHANGED
@@ -10,8 +10,8 @@ class Beanpool
|
|
10
10
|
@connections = Beanpool::Connections.new(ip_array, debug)
|
11
11
|
end
|
12
12
|
|
13
|
-
def put(body,
|
14
|
-
@connections.put_job_to_tube(body,
|
13
|
+
def put(body, options)
|
14
|
+
@connections.put_job_to_tube(body, options)
|
15
15
|
end
|
16
16
|
|
17
17
|
def get(timeout = nil, tube_name = 'default')
|
@@ -30,7 +30,7 @@ class Beanpool
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def get_stat_by_tube(tube_name, stat_name)
|
33
|
-
@connections.stats(tube_name,stat_name
|
33
|
+
@connections.stats(tube_name, stat_name)
|
34
34
|
end
|
35
35
|
|
36
36
|
def get_ready_by_tube(name)
|
@@ -40,4 +40,6 @@ class Beanpool
|
|
40
40
|
def size
|
41
41
|
@connections.stats('default', :current_jobs_ready)
|
42
42
|
end
|
43
|
+
|
44
|
+
|
43
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beanpool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason M.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|