rocketjob 5.2.0.beta1 → 5.2.0.beta2

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
  SHA256:
3
- metadata.gz: 8920ff4a319e838729863bbf2a7a66a4ee003ac9328cc1c3d3942fc59cecab2c
4
- data.tar.gz: 3c5f4927370915b3188295cd181f5b1dc4ae64a17b0cd070e946cfa82b7517c6
3
+ metadata.gz: be987bf17c7505ce19a06f0f15bd612b0d9588a7aed842250b4f094b98b026ef
4
+ data.tar.gz: afb3b94b5f47c4fd462da9732f6b94d87b53f96e9afe22f66592c89eeed3c521
5
5
  SHA512:
6
- metadata.gz: 1395412d271a4a1cde3d1f80fa6d45d5a0e948454b34e6a1d1221631b718d1f4fb16e3683a4a57af1e1f64d724219b70ab65cd84f7a2c9658d67e0608d263973
7
- data.tar.gz: f5b161cf5dcb32126dff42b645b3356707ea74623f011af9a6e7bf0b8fee6403254b302ec5644a85181c207dbe70cfa3a82349be4a2bf52127e68e9f4ebaf5ab
6
+ metadata.gz: 0f71a2a1aa604c1db1babf43ea5865724617515b7f0ea299e438d8fb4bb845d2a4ef21c4bbd5994034cb070c72c6b6f53dfbf45d2b52e576c8a2cb3202e1549a
7
+ data.tar.gz: 969bcffcb4aa38277b99f88188334e28393ed6fa92e5e470214879ec2d169e81a586947daaf3bcaea446ac8766e49e9c7dd328a4131bde0275808eff241a9437
@@ -53,6 +53,19 @@ module RocketJob
53
53
  conn.where(:id.ne => slice.id).count >= throttle_running_workers
54
54
  end
55
55
  end
56
+
57
+ # Returns [Boolean] whether the throttle for this job has been exceeded
58
+ #
59
+ # With a Batch job, allow a higher priority queued job to replace a running one with
60
+ # a lower priority.
61
+ def throttle_running_jobs_exceeded?
62
+ return unless throttle_running_jobs&.positive?
63
+
64
+ # Cannot use this class since it will include instances of parent job classes.
65
+ RocketJob::Job.with(read: {mode: :primary}) do |conn|
66
+ conn.running.where("_type" => self.class.name, :id.ne => id, :priority.lt => priority).count >= throttle_running_jobs
67
+ end
68
+ end
56
69
  end
57
70
  end
58
71
  end
@@ -129,7 +129,7 @@ module RocketJob
129
129
  # Process a single slice from Mongo
130
130
  # Once the slice has been successfully processed it will be removed from the input collection
131
131
  # Returns [Integer] the number of records successfully processed
132
- def rocket_job_process_slice(slice)
132
+ def rocket_job_process_slice(slice, &block)
133
133
  # TODO: Skip records already processed
134
134
  @rocket_job_record_number = slice.first_record_number || 0
135
135
  @rocket_job_slice = slice
@@ -142,7 +142,7 @@ module RocketJob
142
142
  RocketJob::Sliced::Writer::Output.collect(self, slice) do |writer|
143
143
  slice.each do |record|
144
144
  SemanticLogger.named_tagged(record: @rocket_job_record_number) do
145
- writer << rocket_job_batch_perform(slice, record)
145
+ writer << rocket_job_batch_perform(slice, record, &block)
146
146
  processed_records += 1
147
147
  end
148
148
  # JRuby thinks self.rocket_job_record_number= is private and cannot be accessed
@@ -202,7 +202,7 @@ module RocketJob
202
202
  unless new_record?
203
203
  # Fail job iff no other worker has already finished it
204
204
  # Must set write concern to at least 1 since we need the nModified back
205
- result = self.class.with(write: {w: 1}) do |query|
205
+ result = self.class.with(write: {w: 1}) do |query|
206
206
  query.
207
207
  where(id: id, state: :running, sub_state: :processing).
208
208
  update({"$set" => {state: :failed, worker_name: worker_name}})
@@ -128,9 +128,7 @@ module RocketJob
128
128
  # Returns the failed record.
129
129
  # Returns [nil] if there is no failed record
130
130
  def failed_record
131
- if exception && processing_record_number
132
- at(processing_record_number - 1)
133
- end
131
+ at(processing_record_number - 1) if exception && processing_record_number
134
132
  end
135
133
 
136
134
  # Returns [Hash] the slice as a Hash for storage purposes
@@ -1,3 +1,3 @@
1
1
  module RocketJob
2
- VERSION = "5.2.0.beta1".freeze
2
+ VERSION = "5.2.0.beta2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0.beta1
4
+ version: 5.2.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-05 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm