Class: Sidekiq::Cron::Namespace
- Inherits:
-
Object
- Object
- Sidekiq::Cron::Namespace
- Defined in:
- lib/sidekiq/cron/namespace.rb
Class Method Summary collapse
- .all ⇒ Object
- .all_with_count ⇒ Object
- .available_namespaces_provided? ⇒ Boolean
- .count(name = Sidekiq::Cron.configuration.default_namespace) ⇒ Object
Class Method Details
.all ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sidekiq/cron/namespace.rb', line 4 def self.all namespaces = Sidekiq::Cron.configuration.available_namespaces return namespaces if namespaces Sidekiq.redis do |conn| namespaces = conn.keys('cron_jobs:*').collect do |key| key.split(':').last end end # Adds the default namespace if not present has_default = namespaces.detect do |name| name == Sidekiq::Cron.configuration.default_namespace end unless has_default namespaces << Sidekiq::Cron.configuration.default_namespace end namespaces end |
.all_with_count ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/sidekiq/cron/namespace.rb', line 26 def self.all_with_count all.map do |namespace_name| { count: count(namespace_name), name: namespace_name } end end |
.available_namespaces_provided? ⇒ Boolean
43 44 45 |
# File 'lib/sidekiq/cron/namespace.rb', line 43 def self.available_namespaces_provided? !!Sidekiq::Cron.configuration.available_namespaces end |
.count(name = Sidekiq::Cron.configuration.default_namespace) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/sidekiq/cron/namespace.rb', line 35 def self.count(name = Sidekiq::Cron.configuration.default_namespace) out = 0 Sidekiq.redis do |conn| out = conn.scard("cron_jobs:#{name}") end out end |