okcomputer 1.4.0 → 1.5.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7feee2279b4b7c981316b0e8bfaf955c0d0ac503
|
4
|
+
data.tar.gz: 07ca4c4d3e41c368662e4bc102cd2a7091edc06a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39b9456a1387de6c248c7071f8bfc1f7d345f59f83201c847d0a453605dc3e37472af1ec5371bc69f699e7350bed3d1621d32a022af37196b9303b1275defed0
|
7
|
+
data.tar.gz: c48b7ae52c764917e7122dcb71a3df1cb6b872b0683aa3d695e2c62593f0b4b4825c08ad1f44c103cc7fc2350b0caae0411faede1e00dc6858c33bdaebafcfd8
|
@@ -1,14 +1,21 @@
|
|
1
1
|
module OkComputer
|
2
2
|
class DelayedJobBackedUpCheck < SizeThresholdCheck
|
3
|
-
attr_accessor :priority
|
4
|
-
|
5
|
-
|
3
|
+
attr_accessor :priority,
|
4
|
+
:threshold,
|
5
|
+
:queue,
|
6
|
+
:include_locked,
|
7
|
+
:include_errored,
|
8
|
+
:greater_than_priority
|
6
9
|
|
7
10
|
# Public: Initialize a check for backed-up Delayed Job jobs
|
8
11
|
#
|
9
12
|
# priority - Which priority to check for
|
10
|
-
# threshold - An Integer to compare the jobs count against
|
11
|
-
#
|
13
|
+
# threshold - An Integer to compare the jobs count against to consider it backed up
|
14
|
+
# options - Hash of optional parameters
|
15
|
+
# queue - Used to monitor a specific delayed job queue (default: nil)
|
16
|
+
# include_locked - If true, will include currently locked jobs in the query (default: false)
|
17
|
+
# include_errored - If true, will include currently errored jobs in the query (default: false)
|
18
|
+
# greater_than_priority - If true, will include all jobs with a priority value equal or greater than the set value.
|
12
19
|
#
|
13
20
|
# Example:
|
14
21
|
# check = new(10, 50)
|
@@ -18,6 +25,9 @@ module OkComputer
|
|
18
25
|
def initialize(priority, threshold, options = {})
|
19
26
|
self.priority = Integer(priority)
|
20
27
|
self.threshold = Integer(threshold)
|
28
|
+
self.queue = options[:queue]
|
29
|
+
self.include_locked = !!options[:include_locked]
|
30
|
+
self.include_errored = !!options[:include_errored]
|
21
31
|
self.greater_than_priority = !!options[:greater_than_priority]
|
22
32
|
self.name = greater_than_priority ? "Delayed Jobs with priority higher than '#{priority}'" : "Delayed Jobs with priority lower than '#{priority}'"
|
23
33
|
end
|
@@ -30,7 +40,11 @@ module OkComputer
|
|
30
40
|
operator = greater_than_priority ? ">=" : "<="
|
31
41
|
query = Delayed::Job.where("priority #{operator} ?", priority)
|
32
42
|
end
|
33
|
-
|
43
|
+
opts = {}
|
44
|
+
opts[:queue] = queue if queue
|
45
|
+
opts[:locked_at] = nil unless include_locked
|
46
|
+
opts[:last_error] = nil unless include_errored
|
47
|
+
query.where(opts).count
|
34
48
|
end
|
35
49
|
end
|
36
50
|
end
|
@@ -7,7 +7,9 @@ module OkComputer
|
|
7
7
|
# session - The name of the Mongoid session to use. Defaults to the
|
8
8
|
# default session.
|
9
9
|
def initialize(session = :default)
|
10
|
-
if Mongoid.respond_to?(:
|
10
|
+
if Mongoid.respond_to?(:clients) # Mongoid 5
|
11
|
+
self.session = Mongoid::Clients.with_name(session)
|
12
|
+
elsif Mongoid.respond_to?(:sessions) # Mongoid 4
|
11
13
|
self.session = Mongoid::Sessions.with_name(session)
|
12
14
|
end
|
13
15
|
end
|
data/lib/ok_computer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okcomputer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Byrne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|