sidekiq-running 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a849f1752910eba28b10c12cbd0e112cbd35aae0
4
- data.tar.gz: 97a727756281b834260e142a94e476972a171030
3
+ metadata.gz: f34952bfa9e6145c3ea2af494e8d3c05bc6259ff
4
+ data.tar.gz: 5391abdc655fdc5cd63a7b930d8dbaa17c235886
5
5
  SHA512:
6
- metadata.gz: dbe8831b8c9dace44f767940bb89deb718d8b05f5e151a111ab821f6c5abdf72bb703f4b06db361fc462a0136679420ff431a3a3268d4b2ee3eba4aa8655338e
7
- data.tar.gz: b680a15a5a295c1cfd0d96cb8bae31e78ad81963cd32e17622ab54ed9f3f4b3cdb8a93e2af30115e89521dc45c49e09927aea85ffce2a4f6ef9a7f529c7d2fc2
6
+ metadata.gz: a8ff491c0a03cc5b2acc144a6eafa89a3b094fd09e8ab4d2e14044598219a0cca5089bf9337313a0c4007e316c1b268b04d4a9ef7b80f8031297eadf4778beac
7
+ data.tar.gz: a517d8a4aefc5a9f4368bf917b19caebb07b18ccd4f569a6eee2a7881cdec3b49d2f0172645baf218b51825657711abc86b2c1b0d1cb9a5ab15261d38e321bd9
data/README.md CHANGED
@@ -30,17 +30,35 @@ Now, you can run
30
30
  HardWorker.queued?("buy dr.pepper", 10) # => false
31
31
  HardWorker.perform_async("buy dr.pepper", 10)
32
32
  HardWorker.queued?("buy dr.pepper", 10) # => true
33
+
34
+ HardWorker.perform_in(10.minutes, "whatever")
35
+ HardWorker.scheduled?("whatever") # => 2014-10-08 15:46:20 UTC
36
+ HardWorker.scheduled?("this is not scheduled") # => false
37
+
38
+ HardWorker.running?("buy dr.pepper", 10) # => true
39
+ HardWorker.running?("this is not running") # => false
40
+
41
+ # programmed is queued or scheduled
42
+ HardWorker.programmed?("whatever") # => 2014-10-08 15:46:20 UTC
43
+ HardWorker.programmed?("buy dr.pepper", 10) # => true
33
44
  ```
34
45
 
35
46
  ## Methods Available
36
47
  ``Sidekiq::Running`` adds the following class methods to your sidekiq workers:
37
48
 
38
- - queued?(*args)
39
49
  - running?(*args)
40
- - queued_or_running?(*args)
41
- - perform_async_unless_queued(*args)
50
+ - queued?(*args)
51
+ - scheduled?(*args)
52
+
53
+ - running_or_queued?(*args)
54
+ - running_or_programmed?(*args)
55
+
42
56
  - perform_async_unless_running(*args)
43
- - perform_async_unless_queued_or_running(*args)
57
+ - perform_async_unless_queued(*args)
58
+ - perform_async_unless_scheduled(*args)
59
+ - perform_async_unless_programmed(*args)
60
+ - perform_async_unless_running_or_queued(*args)
61
+ - perform_async_unless_running_or_programmed(*args)
44
62
  - queue_name
45
63
 
46
64
  ## Contributing
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Running
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -27,9 +27,27 @@ module Sidekiq
27
27
  end
28
28
  end
29
29
 
30
- def queued_or_running?(*args)
30
+ def scheduled?(*args)
31
+ scheduled = Sidekiq::ScheduledSet.new
32
+ scheduled_job = scheduled.find do |job|
33
+ job.klass == self.name && job.args == args
34
+ end
35
+ scheduled_job && scheduled_job.enqueued_at or false
36
+ end
37
+
38
+ def programmed?(*args)
39
+ queued?(*args) or scheduled?(*args)
40
+ end
41
+
42
+ def running_or_queued?(*args)
31
43
  running?(*args) or queued?(*args)
32
44
  end
45
+ alias_method :queued_or_running?, :running_or_queued?
46
+
47
+ def running_or_programmed?(*args)
48
+ queued?(*args) or programmed?(*args)
49
+ end
50
+ alias_method :programmed_or_running?, :running_or_programmed?
33
51
 
34
52
  def perform_async_unless_queued(*args)
35
53
  perform_async(*args) unless queued?(*args)
@@ -39,9 +57,23 @@ module Sidekiq
39
57
  perform_async(*args) unless running?(*args)
40
58
  end
41
59
 
42
- def perform_async_unless_queued_or_running(*args)
43
- perform_async(*args) unless queued_or_running?(*args)
60
+ def perform_async_unless_scheduled(*args)
61
+ perform_async(*args) unless scheduled?(*args)
62
+ end
63
+
64
+ def perform_async_unless_programmed(*args)
65
+ perform_async(*args) unless programmed?(*args)
66
+ end
67
+
68
+ def perform_async_unelss_running_or_queued(*args)
69
+ perform_async(*args) unless running_or_queued?(*args)
70
+ end
71
+ alias_method :perform_async_unless_queued_or_running, :perform_async_unelss_running_or_queued
72
+
73
+ def perform_async_unless_running_or_programmed(*args)
74
+ perform_async(*args) unless running_or_programmed?(*args)
44
75
  end
76
+ alias_method :perform_async_unless_programmed_or_running, :perform_async_unless_running_or_programmed
45
77
  end
46
78
  end
47
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-running
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Tomás Albornoz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler