chaotic_job 0.8.1 → 0.9.0

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: fe4a1f8c3a72d5b48cb8ef3bdfd725ca55a168484de1bc03cdd945ed43449673
4
+ data.tar.gz: ed0f5d2b690f23d75ac0f272fb2deecfffc46a564248edf18a6f8fe8ea600ca2
5
5
  SHA512:
6
- metadata.gz: e1cf5362e18f450c04c71e65b81375b77f216430239732756c471c521b4da6b8dc4e698c2eb1dc120cea439453be48fcf9511fed7a807ca3f8e7099323487835
7
- data.tar.gz: 313c74e725dfc3ac4a85e8a065a72b3d5ba27f5d353adf78678eead045cc92c4a5769541ab9ed6b038ac182b507c40d97a9c7e650dc6307d3b53bdf62d53495f
6
+ metadata.gz: 2931ae2a67749949986847d7497ee0c69614fa33619d7032ccc9b5c28083b5496d0e9f34e28f2cfe9e5bad0bc97bf856b29645864e28561d3b7f64cac397907b
7
+ data.tar.gz: a522412724d369b052a090c6d4cad5728df2a36bc1280f253d35f83ffbd12b8001ce4e77a6acbb623dcc83dc9e76a78b3bfd6e50566dbea3924d1f32edb6f414
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.9.0] - 2025-06-12
4
+
5
+ - Make journal logging idempotent and add `push` for non-idempotent logging [#12](https://github.com/fractaledmind/chaotic_job/pull/12)
6
+ - A simulation callstack capture needs to perform child jobs as well [#13](https://github.com/fractaledmind/chaotic_job/pull/13)
7
+
3
8
  ## [0.8.1] - 2025-06-12
4
9
 
5
10
  - 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)
@@ -51,7 +51,11 @@ module ChaoticJob
51
51
  job_class = @template.class
52
52
  job_file_path = job_class.instance_method(:perform).source_location&.first
53
53
  tracer = Tracer.new { |tp| tp.path == job_file_path || tp.defined_class == job_class }
54
- callstack = tracer.capture { @template.dup.perform_now }
54
+ callstack = tracer.capture do
55
+ @template.dup.enqueue
56
+ # run the template job as well as any other jobs it may enqueue
57
+ Performer.perform_all
58
+ end
55
59
 
56
60
  @template.class.queue_adapter.enqueued_jobs = []
57
61
  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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim