chaotic_job 0.8.1 → 0.9.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: 849d42915a7b67d65b21d094c0484175003ada6435f04292fd5d25701e591e46
4
- data.tar.gz: 3b2c99e71c3d90986f3bec08c85404262f9a93ae06871a6cc2d93aeefadb5a69
3
+ metadata.gz: 69ba3f56584d3a5c325f63635d547c3959a911e2b435ac7138e3d894b738ca71
4
+ data.tar.gz: 6ca762936806d56ca6daf75777eb9dffe3f392769f6084acaecc1b29065f02e9
5
5
  SHA512:
6
- metadata.gz: e1cf5362e18f450c04c71e65b81375b77f216430239732756c471c521b4da6b8dc4e698c2eb1dc120cea439453be48fcf9511fed7a807ca3f8e7099323487835
7
- data.tar.gz: 313c74e725dfc3ac4a85e8a065a72b3d5ba27f5d353adf78678eead045cc92c4a5769541ab9ed6b038ac182b507c40d97a9c7e650dc6307d3b53bdf62d53495f
6
+ metadata.gz: d56bcb11292c634407d4f05880747e0da4c56b88c99d7c24d128ea66d559c5fc86e59cbb49abc93ca07434fb02c7db11a0f4083d31b3c929ba1f1ca5a69214ad
7
+ data.tar.gz: f2ad5c18837b2f186cbeb58da5ce59ba751649516a6b381dcf3a7c018fda68d73cbcb284e81315064f000f64767ab05200bfe4cacd00969722deb0baf0bf903a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.9.1] - 2025-06-12
4
+
5
+ - The simulation tracer should only capture events on the template job [#14](https://github.com/fractaledmind/chaotic_job/pull/14)
6
+
7
+ ## [0.9.0] - 2025-06-12
8
+
9
+ - Make journal logging idempotent and add `push` for non-idempotent logging [#12](https://github.com/fractaledmind/chaotic_job/pull/12)
10
+ - A simulation callstack capture needs to perform child jobs as well [#13](https://github.com/fractaledmind/chaotic_job/pull/13)
11
+
3
12
  ## [0.8.1] - 2025-06-12
4
13
 
5
14
  - Add pretty `to_s` methods for Scenario and Glitch [#11](https://github.com/fractaledmind/chaotic_job/pull/11)
@@ -10,14 +10,30 @@ module ChaoticJob
10
10
  module Journal
11
11
  extend self
12
12
 
13
+ DEFAULT = Object.new.freeze
14
+
13
15
  def reset!
14
16
  @logs = {}
15
17
  end
16
18
 
17
- def log(item = 1, scope: :default)
19
+ def log(item = DEFAULT, scope: :default)
20
+ @logs ||= {}
21
+ @logs[scope] ||= Set.new
22
+ set = @logs[scope].to_set
23
+ if item != DEFAULT
24
+ set << item
25
+ else
26
+ max = set.to_a.max || 0
27
+ set << max + 1
28
+ end
29
+ item
30
+ end
31
+
32
+ def push(item = true, scope: :default)
18
33
  @logs ||= {}
19
34
  @logs[scope] ||= []
20
- @logs[scope] << item
35
+ array = @logs[scope].to_a
36
+ array << item
21
37
  item
22
38
  end
23
39
 
@@ -26,7 +42,7 @@ module ChaoticJob
26
42
  end
27
43
 
28
44
  def entries(scope: :default)
29
- @logs[scope]
45
+ @logs[scope]&.to_a
30
46
  end
31
47
 
32
48
  def top(scope: :default)
@@ -48,10 +48,12 @@ module ChaoticJob
48
48
  private
49
49
 
50
50
  def capture_callstack
51
- job_class = @template.class
52
- job_file_path = job_class.instance_method(:perform).source_location&.first
53
- tracer = Tracer.new { |tp| tp.path == job_file_path || tp.defined_class == job_class }
54
- callstack = tracer.capture { @template.dup.perform_now }
51
+ tracer = Tracer.new { |tp| tp.defined_class == @template.class }
52
+ callstack = tracer.capture do
53
+ @template.dup.enqueue
54
+ # run the template job as well as any other jobs it may enqueue
55
+ Performer.perform_all
56
+ end
55
57
 
56
58
  @template.class.queue_adapter.enqueued_jobs = []
57
59
  callstack
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChaoticJob
4
- VERSION = "0.8.1"
4
+ VERSION = "0.9.1"
5
5
  end
data/lib/chaotic_job.rb CHANGED
@@ -26,6 +26,18 @@ module ChaoticJob
26
26
  end
27
27
  end
28
28
 
29
+ def self.push_to_journal!(item = nil, scope: nil)
30
+ if item && scope
31
+ Journal.push(item, scope: scope)
32
+ elsif item
33
+ Journal.push(item)
34
+ elsif scope
35
+ Journal.push(scope: scope)
36
+ else
37
+ Journal.push
38
+ end
39
+ end
40
+
29
41
  def self.journal_entries(scope: nil)
30
42
  if scope
31
43
  Journal.entries(scope: scope)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chaotic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim