lib/sidekiq/limit_fetch/global/semaphore.rb in sidekiq-limit_fetch-2.1.3 vs lib/sidekiq/limit_fetch/global/semaphore.rb in sidekiq-limit_fetch-2.2.0
- old
+ new
@@ -16,20 +16,28 @@
value = redis {|it| it.get "#{PREFIX}:limit:#@name" }
value.to_i if value
end
def limit=(value)
- redis {|it| it.set "#{PREFIX}:limit:#@name", value }
+ if value
+ redis {|it| it.set "#{PREFIX}:limit:#@name", value }
+ else
+ redis {|it| it.del "#{PREFIX}:limit:#@name" }
+ end
end
def process_limit
value = redis {|it| it.get "#{PREFIX}:process_limit:#@name" }
value.to_i if value
end
def process_limit=(value)
- redis {|it| it.set "#{PREFIX}:process_limit:#@name", value }
+ if value
+ redis {|it| it.set "#{PREFIX}:process_limit:#@name", value }
+ else
+ redis {|it| it.del "#{PREFIX}:process_limit:#@name" }
+ end
end
def acquire
Selector.acquire([@name], determine_namespace).size > 0
end
@@ -118,9 +126,18 @@
Locked queue processes:
#{probed_processes.sort.join "\n"}
Busy queue processes:
#{busy_processes.sort.join "\n"}
+
+ Limit:
+ #{limit.inspect}
+
+ Process limit:
+ #{process_limit.inspect}
+
+ Blocking:
+ #{blocking?}
END
end
def remove_locks_except!(processes)
locked_processes = probed_processes.uniq