sidekiq-running 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/README.md +22 -4
- data/lib/sidekiq/running/version.rb +1 -1
- data/lib/sidekiq/running.rb +35 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f34952bfa9e6145c3ea2af494e8d3c05bc6259ff
|
4
|
+
data.tar.gz: 5391abdc655fdc5cd63a7b930d8dbaa17c235886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
-
|
41
|
-
-
|
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
|
-
-
|
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
|
data/lib/sidekiq/running.rb
CHANGED
@@ -27,9 +27,27 @@ module Sidekiq
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
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
|
43
|
-
perform_async(*args) unless
|
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.
|
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-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|