okcomputer 1.4.0 → 1.5.0

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: 8f2e2e1fbf0bd12e43eeed9987395392fefc5820
4
- data.tar.gz: 071f6f634691d45b44c5f134c2d3b87534834199
3
+ metadata.gz: 7feee2279b4b7c981316b0e8bfaf955c0d0ac503
4
+ data.tar.gz: 07ca4c4d3e41c368662e4bc102cd2a7091edc06a
5
5
  SHA512:
6
- metadata.gz: 36ef20a1ceae3441cb1ed24f5b78d1596b51724aad107a62f5b5850901b0138a1fa3e686307469749247e91ac129a0c8c574f3d152c6f5633d9aea34a66be658
7
- data.tar.gz: 8f6dd78954876861034bd82052159cd7b759bfa4a7b7e25845a4d90ea86908e57c78e579bb9928510f44b3dc2b1b25e7af206045cba2050dd8351ac15f794271
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
- attr_accessor :threshold
5
- attr_accessor :greater_than_priority
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
- # to consider it backed up
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
- query.where(:locked_at => nil, :last_error => nil).count
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?(:sessions)
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
@@ -1,3 +1,3 @@
1
1
  module OkComputer
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
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.0
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-02-07 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3