rocketjob 5.0.0.beta4 → 5.0.0.rc1

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: '048d247981e5131c03505a00a99945bc9efb9a1d862d629a5da1db9bbd2aa083'
4
- data.tar.gz: 361373a9b8a8709276fc9198be95bd7f197b54c7dc067e59d91d2f648f13653f
3
+ metadata.gz: c53fb037073ba38fd229b6a0573a2e0a28a1f28bbb0750bc895f2f2d46b57d44
4
+ data.tar.gz: c5ab8fcbe268aa97909448b4e053cf54698b1f690fe537899f1ed4a5c7f7a1ed
5
5
  SHA512:
6
- metadata.gz: e955117f6a72063a9de9bbea3d7ced0e1e4afa1943ff72af5f443f9fc1b2c59babeb687fc0d3924892635a328605b9421b11ee3ea18de2681f159be95595ebcf
7
- data.tar.gz: e22f2bea9056da23229a29cc6fd6005dc09d8ae0a73b8bac30704636ace2cd7d347c1cfa8fcffed89680fe6b591eb77dfbeb925185594330772f11c8f8b53b29
6
+ metadata.gz: 69973ec5d30e2d9a63a338119121decb9c20ce8b5d0aba3d9a566799f80eaad626bb2055361bda7cbf5e60085b0fd82c68082f499e151d3a982659457173c5ff
7
+ data.tar.gz: 8a7b75c3d55fdc1c38c549efc91b8e7cf806ac7aa323a2c0ed1ede9f7e4b7518840d282b172446e5f5f9762685dd5a0639ce9e5fc151d173a59212a0ac5d5ee7
@@ -43,9 +43,11 @@ module RocketJob
43
43
 
44
44
  # Returns [Boolean] whether the throttle for this job has been exceeded
45
45
  def throttle_running_slices_exceeded?(slice)
46
- throttle_running_slices &&
47
- (throttle_running_slices != 0) &&
48
- (input.running.where(:id.ne => slice.id).count >= throttle_running_slices)
46
+ return unless throttle_running_slices&.positive?
47
+
48
+ input.running.with(read: {mode: :primary}) do |conn|
49
+ conn.where(:id.ne => slice.id).count >= throttle_running_slices
50
+ end
49
51
  end
50
52
 
51
53
  end
@@ -32,12 +32,12 @@ module RocketJob
32
32
  field :target_url, type: String, user_editable: true
33
33
 
34
34
  # Any optional arguments to pass through to the IOStreams source and/or target.
35
- field :source_args, type: Hash, default: -> { {} }
36
- field :target_args, type: Hash, default: -> { {} }
35
+ field :source_args, type: Hash, default: -> { {} }, user_editable: true
36
+ field :target_args, type: Hash, default: -> { {} }, user_editable: true
37
37
 
38
38
  # Any optional IOStreams streams to apply to the source and/or target.
39
- field :source_streams, type: Hash, default: -> { {none: nil} }
40
- field :target_streams, type: Hash, default: -> { {none: nil} }
39
+ field :source_streams, type: Hash, default: -> { {none: nil} }, user_editable: true
40
+ field :target_streams, type: Hash, default: -> { {none: nil} }, user_editable: true
41
41
 
42
42
  # Data to upload, instead of supplying `:input_file_name` above.
43
43
  # Note: Data must be less than 15MB after compression.
@@ -63,12 +63,6 @@ module RocketJob
63
63
  self.percent_complete = 100
64
64
  end
65
65
 
66
- private
67
-
68
- def set_description
69
- self.description = "Copying to #{target_url}"
70
- end
71
-
72
66
  def source_path
73
67
  source = IOStreams.path(source_url, **decrypt_args(source_args))
74
68
  apply_streams(source, source_streams)
@@ -81,6 +75,12 @@ module RocketJob
81
75
  target
82
76
  end
83
77
 
78
+ private
79
+
80
+ def set_description
81
+ self.description = "Copying to #{target_url}"
82
+ end
83
+
84
84
  def apply_streams(path, streams)
85
85
  streams.each_pair { |stream, args| path.stream(stream.to_sym, args.nil? ? {} : decrypt_args(args)) }
86
86
  end
@@ -72,8 +72,8 @@ module RocketJob
72
72
  DirmonEntry.enabled.each do |entry|
73
73
  entry.each do |iopath|
74
74
  # S3 files are only visible once completely uploaded.
75
- if iopath.is_a?(IOStreams::Paths::S3)
76
- logger.info("S3 File: #{iopath}. Starting: #{entry.job_class_name}")
75
+ unless iopath.partial_files_visible?
76
+ logger.info("File: #{iopath}. Starting: #{entry.job_class_name}")
77
77
  entry.later(iopath)
78
78
  next
79
79
  end
@@ -81,6 +81,7 @@ module RocketJob
81
81
  # BSON Keys cannot contain periods
82
82
  key = iopath.to_s.tr('.', '_')
83
83
  previous_size = previous_file_names[key]
84
+ # Check every few minutes for a file size change before trying to process the file.
84
85
  size = check_file(entry, iopath, previous_size)
85
86
  new_file_names[key] = size if size
86
87
  end
@@ -36,10 +36,12 @@ module RocketJob
36
36
 
37
37
  # Returns [Boolean] whether the throttle for this job has been exceeded
38
38
  def throttle_running_jobs_exceeded?
39
- throttle_running_jobs &&
40
- (throttle_running_jobs != 0) &&
41
- # Cannot use the class since it will include instances of parent job classes.
42
- (RocketJob::Job.running.where('_type' => self.class.name, :id.ne => id).count >= throttle_running_jobs)
39
+ return unless throttle_running_jobs&.positive?
40
+
41
+ # Cannot use this class since it will include instances of parent job classes.
42
+ RocketJob::Job.with(read: {mode: :primary}) do |conn|
43
+ conn.running.where('_type' => self.class.name, :id.ne => id).count >= throttle_running_jobs
44
+ end
43
45
  end
44
46
  end
45
47
  end
@@ -61,8 +61,10 @@ module RocketJob
61
61
  # Requeues all jobs that were running on a server that died
62
62
  def requeue_dead_server(server_name)
63
63
  # Need to requeue paused, failed since user may have transitioned job before it finished
64
- where(:state.in => %i[running paused failed]).each do |job|
65
- job.requeue!(server_name) if job.may_requeue?(server_name)
64
+ with(read: {mode: :primary}) do |conn|
65
+ conn.where(:state.in => %i[running paused failed]).each do |job|
66
+ job.requeue!(server_name) if job.may_requeue?(server_name)
67
+ end
66
68
  end
67
69
  end
68
70
 
@@ -12,7 +12,9 @@ module RocketJob
12
12
 
13
13
  # Returns [true|false] whether another instance of this job is already active
14
14
  def rocket_job_singleton_active?
15
- self.class.where(:state.in => %i[running queued], :id.ne => id).exists?
15
+ self.class.with(read: {mode: :primary}) do |conn|
16
+ conn.where(:state.in => %i[running queued], :id.ne => id).exists?
17
+ end
16
18
  end
17
19
 
18
20
  private
@@ -1,3 +1,3 @@
1
1
  module RocketJob
2
- VERSION = '5.0.0.beta4'.freeze
2
+ VERSION = '5.0.0.rc1'.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.0.0.beta4
4
+ version: 5.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-14 00:00:00.000000000 Z
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm