ductwork 0.8.0 → 0.8.1

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: f64abfa6d358cd7b225baae1b801894032936bef4de86ff0843e3163552aa530
4
- data.tar.gz: aedd9daa71379091503375926ea4863a7834193a1701ee265a9b0b99a7fbfe50
3
+ metadata.gz: 6fde482283602dcf363baed46b5d8468757ddb8f6cc6fabb9b9d5e37497e10f4
4
+ data.tar.gz: 3aa0f1a9aa6f77b47997b64b246ed3dc7371e63554943110de8e06f98135f9d3
5
5
  SHA512:
6
- metadata.gz: 85598e36b5edb64f33217d19cb2f2af66e6991c68f74c0a8ede9c445d88884bd804da2b381b2dd9cdeaa6a6936a340628af25c45ff259632f36d1c4429665bcb
7
- data.tar.gz: 4f59ad232e7a00c8e34403dfb8412af7e7351f0d921b3fd7fc6c27ee10524a1bd37e57bd18aa020c9e7daf1c3374127927e54474302364f3ee6962d157b9e468
6
+ metadata.gz: bc475be1df97dada6099f8210b5694cbc4d90e5466d565a50674bac796fc252923f19a18e6beae3cf673db8d25fccf4bfb8178622d8574fd0e2b911e27dc8a0f
7
+ data.tar.gz: e1caa07d54fe23a2f2ea1b90809371a53bfd791eba6751bab9b65dac254c7f7935cf54f4b217adb68e084abd478192000090c91005d644188f64e2d7930264fd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Ductwork Changelog
2
2
 
3
+ ## [0.8.1]
4
+
5
+ - fix: properly wrap "units of work" in rails application executor in pipeline advancer
6
+ - fix: remove wrapping thread creation with the rails application executor - these threads are long-running so they should not be wrapped; later commits will wrap each individual "unit of work" with the executor as recommended
7
+ - fix: move pipeline advancer creation into thread initialization block - this effectively doesn't change anything but is useful in case we need to do something on the advancer thread in the initializer
8
+ - fix: move job worker creation into thread initialization block - this effectively doesn't change anything but is useful in case we need to do something on the worker thread in the initializer
9
+
3
10
  ## [0.8.0]
4
11
 
5
12
  - chore: re-organize `Ductwork::CLI` class
data/LICENSE.txt CHANGED
@@ -4,7 +4,7 @@ the LGPLv3.0 license. Please see below for license text:
4
4
  GNU LESSER GENERAL PUBLIC LICENSE
5
5
  Version 3, 29 June 2007
6
6
 
7
- Copyright (c) 2024-2025 Tyler Ewing
7
+ Copyright (c) 2024-2025 Pen and Paper Solutions LLC
8
8
  Everyone is permitted to copy and distribute verbatim copies
9
9
  of this license document, but changing it is not allowed.
10
10
 
@@ -51,17 +51,15 @@ module Ductwork
51
51
 
52
52
  def create_threads
53
53
  worker_count.times.map do |i|
54
- job_worker = Ductwork::Processes::JobWorker.new(
55
- pipeline,
56
- running_context
57
- )
58
54
  Ductwork.logger.debug(
59
55
  msg: "Creating new thread",
60
56
  role: :job_worker_runner,
61
57
  pipeline: pipeline
62
58
  )
63
59
  thread = Thread.new do
64
- job_worker.run
60
+ Ductwork::Processes::JobWorker
61
+ .new(pipeline, running_context)
62
+ .run
65
63
  end
66
64
  thread.name = "ductwork.job_worker.#{i}"
67
65
 
@@ -10,8 +10,9 @@ module Ductwork
10
10
 
11
11
  def run # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
12
12
  run_hooks_for(:start)
13
+
13
14
  while running_context.running?
14
- id = Ductwork::Record.uncached do
15
+ id = Ductwork.wrap_with_app_executor do
15
16
  Ductwork::Pipeline
16
17
  .in_progress
17
18
  .where(klass: klass, claimed_for_advancing_at: nil)
@@ -24,12 +25,14 @@ module Ductwork
24
25
  end
25
26
 
26
27
  if id.present?
27
- rows_updated = Ductwork::Pipeline
28
- .where(id: id, claimed_for_advancing_at: nil)
29
- .update_all(
30
- claimed_for_advancing_at: Time.current,
31
- status: "advancing"
32
- )
28
+ rows_updated = Ductwork.wrap_with_app_executor do
29
+ Ductwork::Pipeline
30
+ .where(id: id, claimed_for_advancing_at: nil)
31
+ .update_all(
32
+ claimed_for_advancing_at: Time.current,
33
+ status: "advancing"
34
+ )
35
+ end
33
36
 
34
37
  if rows_updated == 1
35
38
  Ductwork.logger.debug(
@@ -39,23 +42,31 @@ module Ductwork
39
42
  role: :pipeline_advancer
40
43
  )
41
44
 
42
- pipeline = Ductwork::Pipeline.find(id)
43
- pipeline.advance!
45
+ pipeline = Ductwork.wrap_with_app_executor do
46
+ pipeline = Ductwork::Pipeline.find(id)
47
+ pipeline.advance!
44
48
 
45
- Ductwork.logger.debug(
46
- msg: "Pipeline advanced",
47
- pipeline_id: id,
48
- pipeline: klass,
49
- role: :pipeline_advancer
50
- )
49
+ Ductwork.logger.debug(
50
+ msg: "Pipeline advanced",
51
+ pipeline_id: id,
52
+ pipeline: klass,
53
+ role: :pipeline_advancer
54
+ )
51
55
 
52
- # release the pipeline and set last advanced at so it doesnt block.
53
- # we're not using a queue so we have to use a db timestamp
54
- pipeline.update!(
55
- claimed_for_advancing_at: nil,
56
- last_advanced_at: Time.current,
57
- status: "in_progress"
58
- )
56
+ # rubocop:todo Metrics/BlockNesting
57
+ status = pipeline.completed? ? "completed" : "in_progress"
58
+ # rubocop:enable Metrics/BlockNesting
59
+
60
+ # release the pipeline and set last advanced at so it doesn't
61
+ # block. we're not using a queue so we have to use a db
62
+ # timestamp
63
+ ensure
64
+ pipeline.update!(
65
+ claimed_for_advancing_at: nil,
66
+ last_advanced_at: Time.current,
67
+ status: status
68
+ )
69
+ end
59
70
  else
60
71
  Ductwork.logger.debug(
61
72
  msg: "Did not claim pipeline, avoided race condition",
@@ -46,20 +46,15 @@ module Ductwork
46
46
 
47
47
  def create_threads
48
48
  klasses.map do |klass|
49
- pipeline_advancer = Ductwork::Processes::PipelineAdvancer.new(
50
- running_context,
51
- klass
52
- )
53
-
54
49
  Ductwork.logger.debug(
55
50
  msg: "Creating new thread",
56
51
  role: :pipeline_advancer_runner,
57
52
  pipeline: klass
58
53
  )
59
54
  thread = Thread.new do
60
- Ductwork.wrap_with_app_executor do
61
- pipeline_advancer.run
62
- end
55
+ Ductwork::Processes::PipelineAdvancer
56
+ .new(running_context, klass)
57
+ .run
63
58
  end
64
59
  thread.name = "ductwork.pipeline_advancer.#{klass}"
65
60
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ductwork
4
- VERSION = "0.8.0"
4
+ VERSION = "0.8.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ductwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Ewing