beanqueue 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.1.0 2011-10-20
2
+
3
+ * 2 minor enhancements:
4
+ * Some typos in README
5
+ * Changes in configuration API for compliance with Beanworker
6
+
1
7
  === 0.0.1 2011-10-19
2
8
 
3
9
  * 1 major enhancement:
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.load './config/beanstalk.yml'
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: 60.seconds, # job will be re-put after this time of execution
64
- # default is 2.minutes
65
- priority: 100, # beanstalk inner priority
66
- # I prefer to use grouping instead
67
- delay: 5, # delay job queuing
68
- # default is 0
69
- fork: true # does job should be performed in fork
70
- # default is set in worker/job definition
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.1'
4
+ VERSION = '0.1.0'
5
5
 
6
6
  class << self
7
- def load(yaml_path)
8
- config = YAML.load(open(yaml_path))
9
- if config['nodes']
10
- connect *(config['nodes'].map { |node| "#{node['host']}:#{node['port']}" })
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
- connect "#{config['host']}:#{config['port']}"
12
+ "#{hash['host']}:#{hash['port']}"
13
13
  end
14
- end
14
+ end
15
15
 
16
- def connect(*nodes)
17
- @connection = Beanstalk::Pool.new nodes.to_a
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.load Rails.root.join('config', 'beanstalk.yml')
29
+ Beanqueue.connect Beanqueue.get_params(Rails.root.join('config', 'beanstalk.yml'))
30
30
  end
@@ -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
- puts conn
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 test_load
18
- conn = Beanqueue.load File.expand_path('../configs/one.yml', __FILE__)
19
- assert conn && conn.instance_eval { @connections['localhost:11300'] }, 'connection from one-node YAML config should be set up'
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
- conn = Beanqueue.load File.expand_path('../configs/many.yml', __FILE__)
22
- assert conn && conn.instance_eval { @connections['localhost:11300'] }, 'connection from many-nodes YAML config should be set up'
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.1
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-19 00:00:00.000000000Z
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: &7981320 !ruby/object:Gem::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: *7981320
24
+ version_requirements: *21543920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
27
- requirement: &7980780 !ruby/object:Gem::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: *7980780
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