Permalink
Browse files

Cleanup

  • Loading branch information...
1 parent d805fdd commit 3611fc0a6acadf30f349fb688efa7cac26cd4652 @mperham committed Apr 18, 2011
Showing with 10 additions and 6 deletions.
  1. +4 −0 lib/girl_friday.rb
  2. +1 −1 lib/girl_friday/persistence.rb
  3. +4 −4 lib/girl_friday/work_queue.rb
  4. +1 −1 test/test_girl_friday.rb
View
@@ -24,6 +24,9 @@ def self.status
# new work; any new work pushed onto the queues will be pushed onto the
# backlog (and persisted). This method will block until all queues are
# quiet or the timeout has passed.
+ #
+ # Note that shutdown! just works with existing queues. If you create a
+ # new queue, it will act as normal.
def self.shutdown!(timeout=30)
queues = []
ObjectSpace.each_object(WorkQueue).each { |q| queues << q }
@@ -43,6 +46,7 @@ def self.shutdown!(timeout=30)
m.synchronize do
var.wait(m, timeout)
end
+ count
end
end
@@ -1,5 +1,5 @@
module GirlFriday
- module Persistence
+ module Store
class InMemory
def initialize(name, options)
@@ -15,9 +15,9 @@ def initialize(name, options={}, &block)
@shutdown = false
@ready_workers = []
@busy_workers = []
- @started_at = Time.now.to_i
+ @created_at = Time.now.to_i
@total_processed = @total_errors = @total_queued = 0
- @persister = (options[:store] || Persistence::InMemory).new(name, (options[:store_config] || []))
+ @persister = (options[:store] || Store::InMemory).new(name, (options[:store_config] || []))
start
end
@@ -36,8 +36,8 @@ def status
:total_queued => @total_queued,
:total_processed => @total_processed,
:total_errors => @total_errors,
- :uptime => Time.now.to_i - @started_at,
- :started_at => @started_at,
+ :uptime => Time.now.to_i - @created_at,
+ :created_at => @created_at,
}
}
end
View
@@ -99,7 +99,7 @@ def test_should_persist_with_redis
end
async_test do |cb|
- queue = GirlFriday::WorkQueue.new('test', :size => 2, :store => GirlFriday::Persistence::Redis) do |msg|
+ queue = GirlFriday::WorkQueue.new('test', :size => 2, :store => GirlFriday::Store::Redis) do |msg|
incr.call
cb.call if count == total
end

0 comments on commit 3611fc0

Please sign in to comment.