beanqueue 0.0.1 → 0.1.0
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/History.txt +6 -0
- data/README.rdoc +13 -9
- data/lib/beanqueue.rb +10 -10
- data/test/test_beanqueue.rb +9 -7
- metadata +6 -6
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -50,7 +50,7 @@ or for multiple servers:
|
|
50
50
|
|
51
51
|
you can load YAML from non-Rails app with:
|
52
52
|
|
53
|
-
Beanqueue.
|
53
|
+
Beanqueue.connect Beanqueue.get_params('./config/beanstalk.yml')
|
54
54
|
|
55
55
|
== USAGE:
|
56
56
|
|
@@ -60,14 +60,18 @@ or with params:
|
|
60
60
|
|
61
61
|
Beanqueue.push 'some.job',
|
62
62
|
{ param1: 'val1', param2: 'val2' },
|
63
|
-
timeout:
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
63
|
+
timeout: 60.seconds, # job will be re-put after this time of execution
|
64
|
+
# default is 2.minutes
|
65
|
+
|
66
|
+
priority: 100, # beanstalk inner priority, bigger - higher
|
67
|
+
# default is 65536
|
68
|
+
# I prefer to use grouping instead
|
69
|
+
|
70
|
+
delay: 5, # delay job queuing
|
71
|
+
# default is 0
|
72
|
+
|
73
|
+
fork: true # does job should be performed in fork
|
74
|
+
# default is set in worker/job definition
|
71
75
|
|
72
76
|
== LICENSE:
|
73
77
|
|
data/lib/beanqueue.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'beanstalk-client'
|
2
2
|
|
3
3
|
module Beanqueue
|
4
|
-
VERSION = '0.0
|
4
|
+
VERSION = '0.1.0'
|
5
5
|
|
6
6
|
class << self
|
7
|
-
def
|
8
|
-
|
9
|
-
if
|
10
|
-
|
7
|
+
def get_params(yaml_path)
|
8
|
+
hash = YAML.load(open(yaml_path))
|
9
|
+
if hash['nodes']
|
10
|
+
hash['nodes'].map { |node| "#{node['host']}:#{node['port']}" }
|
11
11
|
else
|
12
|
-
|
12
|
+
"#{hash['host']}:#{hash['port']}"
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
15
15
|
|
16
|
-
def connect(
|
17
|
-
@connection = Beanstalk::Pool.new nodes
|
16
|
+
def connect(nodes)
|
17
|
+
@connection = Beanstalk::Pool.new(nodes.is_a?(Array) ? nodes : [nodes])
|
18
18
|
end
|
19
19
|
|
20
20
|
def push(name, args={}, opts={})
|
@@ -26,5 +26,5 @@ module Beanqueue
|
|
26
26
|
end
|
27
27
|
|
28
28
|
if defined? Rails
|
29
|
-
Beanqueue.
|
29
|
+
Beanqueue.connect Beanqueue.get_params(Rails.root.join('config', 'beanstalk.yml'))
|
30
30
|
end
|
data/test/test_beanqueue.rb
CHANGED
@@ -10,16 +10,18 @@ class TestBeanqueue < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def test_connect
|
12
12
|
conn = Beanqueue.connect 'localhost:11300'
|
13
|
-
assert conn && conn.instance_eval { @connections['localhost:11300'] }, 'connection should be set up'
|
14
|
-
|
13
|
+
assert conn && conn.instance_eval { @connections['localhost:11300'] }, 'connection should be set up from string'
|
14
|
+
|
15
|
+
conn = Beanqueue.connect ['localhost:11300']
|
16
|
+
assert conn && conn.instance_eval { @connections['localhost:11300'] }, 'connection should be set up from array'
|
15
17
|
end
|
16
18
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
19
|
+
def test_get_params
|
20
|
+
params = Beanqueue.get_params File.expand_path('../configs/one.yml', __FILE__)
|
21
|
+
assert_equal 'localhost:11300', params, 'params from one-node YAML config are wrong'
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
params = Beanqueue.get_params File.expand_path('../configs/many.yml', __FILE__)
|
24
|
+
assert_equal ['localhost:11300', '192.168.1.1:11301'], params, 'params from many-nodes YAML config are wrong'
|
23
25
|
end
|
24
26
|
|
25
27
|
def test_push
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beanqueue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beanstalk-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &21543920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21543920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
27
|
-
requirement: &
|
27
|
+
requirement: &21542600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.12'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21542600
|
36
36
|
description: ! 'This is a beanstalk-based job-queueing-manager, replacement for gem
|
37
37
|
''stalker'' with additions:
|
38
38
|
|