girl_friday 0.9.3 → 0.9.4

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.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changes
2
2
  ================
3
3
 
4
+ 0.9.4
5
+ ---------
6
+
7
+ * You can now pass in an existing Redis instance - :store\_config => [{ :redis => $redis }]
8
+
4
9
  0.9.3
5
10
  ---------
6
11
 
data/README.md CHANGED
@@ -36,6 +36,14 @@ In your Rails app, create a `config/initializers/girl_friday.rb` which defines y
36
36
  ImageCrawler.process(msg)
37
37
  end
38
38
 
39
+ SCRAPE_QUEUE = GirlFriday::WorkQueue.new(:scrape_sites, :size => 4, :store => GirlFriday::Store::Redis, :store_config => [{ :host => 'host' }] do |msg|
40
+ Page.scrape(msg)
41
+ end
42
+
43
+ TRANSCODE_QUEUE = GirlFriday::WorkQueue.new(:scrape_sites, :size => 4, :store => GirlFriday::Store::Redis, :store_config => [{ :redis => $redis }] do |msg|
44
+ VideoProcessor.transcode(msg)
45
+ end
46
+
39
47
  :size is the number of workers to spin up and defaults to 5. Keep in mind, ActiveRecord defaults to a connection pool size of 5 so if your workers are accessing the database you'll want to ensure that the connection pool is large enough by modifying `config/database.yml`.
40
48
 
41
49
  In your controller action or model, you can call `#push(msg)`
@@ -48,7 +56,6 @@ Your message processing block should **not** access any instance data or variabl
48
56
 
49
57
  You can call `GirlFriday::WorkQueue.immediate!` to process jobs immediately, which is helpful when testing. `GirlFriday::WorkQueue.queue!` will revert this & jobs will be processed by actors.
50
58
 
51
-
52
59
  More Detail
53
60
  --------------------
54
61
 
data/lib/girl_friday.rb CHANGED
@@ -59,7 +59,12 @@ module GirlFriday
59
59
 
60
60
  end
61
61
 
62
- at_exit do
63
- GirlFriday.shutdown!
62
+ begin
63
+ ObjectSpace.each_object(GirlFriday).to_a
64
+ at_exit do
65
+ GirlFriday.shutdown!
66
+ end
67
+ rescue RuntimeError
68
+ $stderr.puts "[warn] girl_friday will not shut down cleanly, pass -X+O to JRuby to enable ObjectSpace"
64
69
  end
65
70
 
@@ -48,7 +48,7 @@ module GirlFriday
48
48
  end
49
49
 
50
50
  def redis
51
- @redis ||= ::Redis.new(*@opts)
51
+ @redis ||= (@opts.delete(:redis) || ::Redis.new(*@opts))
52
52
  end
53
53
  end
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module GirlFriday
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -109,6 +109,37 @@ class TestGirlFriday < MiniTest::Unit::TestCase
109
109
  end
110
110
  end
111
111
 
112
+ def test_should_persist_with_redis_instance
113
+ begin
114
+ require 'redis'
115
+ redis = Redis.new
116
+ redis.flushdb
117
+ rescue LoadError
118
+ return puts "Skipping redis test, 'redis' gem not found: #{$!.message}"
119
+ rescue Errno::ECONNREFUSED
120
+ return puts 'Skipping redis test, not running locally accepting connections over UNIX socket'
121
+ end
122
+
123
+ mutex = Mutex.new
124
+ total = 100
125
+ count = 0
126
+ incr = Proc.new do
127
+ mutex.synchronize do
128
+ count += 1
129
+ end
130
+ end
131
+
132
+ async_test do |cb|
133
+ queue = GirlFriday::WorkQueue.new('test', :size => 2, :store => GirlFriday::Store::Redis, :store_config => [{ :redis => redis }]) do |msg|
134
+ incr.call
135
+ cb.call if count == total
136
+ end
137
+ total.times do
138
+ queue.push(:text => 'foo')
139
+ end
140
+ end
141
+ end
142
+
112
143
  def test_should_allow_graceful_shutdown
113
144
  mutex = Mutex.new
114
145
  total = 100
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: girl_friday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-02 00:00:00.000000000 -07:00
13
- default_executable:
12
+ date: 2011-08-23 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: sinatra
17
- requirement: &2164886320 !ruby/object:Gem::Requirement
16
+ requirement: &13466240 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: '1.0'
23
22
  type: :development
24
23
  prerelease: false
25
- version_requirements: *2164886320
24
+ version_requirements: *13466240
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: rake
28
- requirement: &2164885900 !ruby/object:Gem::Requirement
27
+ requirement: &13465820 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,7 +32,7 @@ dependencies:
33
32
  version: '0'
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *2164885900
35
+ version_requirements: *13465820
37
36
  description: Background processing, simplified
38
37
  email:
39
38
  - mperham@gmail.com
@@ -72,7 +71,6 @@ files:
72
71
  - test/test_girl_friday.rb
73
72
  - test/test_girl_friday_immediately.rb
74
73
  - test/timed_queue.rb
75
- has_rdoc: true
76
74
  homepage: http://github.com/mperham/girl_friday
77
75
  licenses: []
78
76
  post_install_message:
@@ -93,13 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
91
  version: '0'
94
92
  requirements: []
95
93
  rubyforge_project: girl_friday
96
- rubygems_version: 1.6.2
94
+ rubygems_version: 1.8.6
97
95
  signing_key:
98
96
  specification_version: 3
99
97
  summary: Background processing, simplified
100
- test_files:
101
- - test/helper.rb
102
- - test/test_batch.rb
103
- - test/test_girl_friday.rb
104
- - test/test_girl_friday_immediately.rb
105
- - test/timed_queue.rb
98
+ test_files: []