aeternitas 2.0.0.rc1 → 2.0.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: 2c1d90d4cf7395ae79d96e09c0e3ba2ff163d96a31c3283eef8ec516ca2e2645
4
- data.tar.gz: 1a245a59727f923ce5e1054e7c043c684f7d14e9b37f4ec65265b30843ff41b1
3
+ metadata.gz: 072e9c223b68767bac14dab82e9f490910d67b38d472eb539a62e63989599437
4
+ data.tar.gz: d4d1314d44369bf830804018da841cdafc79365eb9da057e9a3b2ad1771297d4
5
5
  SHA512:
6
- metadata.gz: 8764240e6d8e929f4ed351886daf38df7a3d76bb09b41631ee344be52cb8322b600eec8750aeb20b2cb3f3397c819b3b3fdf930dc47641aca9bc57a97597bc80
7
- data.tar.gz: fd450bbf6f00ea6341987974741809fcf0a78c6ef7909ac29af9aeae8c87a603e5d36824748bef7f2cce01d9658b14f8d3222aa8d41a3fb5b2f8b70313c9e4bd
6
+ metadata.gz: 44ff2e37d3138379473d31728f4b0ecbe1918d7573c350cbf5b0413901d0473b586c33b8b57d40191d880fe9d34b3f2fa0b819950f08bff7f8e2bb96d3b6ad1d
7
+ data.tar.gz: f71e7d7baad36c2dc46894b60f2846025a9f5ca39e301de7e6a5f4a7e2554e30c08e4bab7948b53b5b8faf745bdb89f8002a73e8283affd283a97d5608b913e6
data/.gitattributes CHANGED
File without changes
File without changes
File without changes
data/.gitignore CHANGED
File without changes
data/.ruby-version CHANGED
File without changes
data/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [2.0.0] - Unreleased
10
+ ## [2.0.0] - 2025-08-11
11
11
 
12
12
  This is a major rewrite of Æternitas with the primary goals of removing the Redis and Sidekiq dependencies and simplifying the core functionality.
13
13
 
@@ -24,6 +24,7 @@ This is a major rewrite of Æternitas with the primary goals of removing the Red
24
24
  - Thundering Herd Prevention: The `PollJob` now intelligently staggers retries when a `GuardIsLocked` error occurs, preventing many jobs from retrying simultaneously and overwhelming a resource.
25
25
  - Configurable Metrics: Added `Aeternitas.config.metrics_enabled` and `Aeternitas.config.metric_retention_period` to give users control over metrics collection and data retention.
26
26
  - Built-in Maintenance Jobs: Added `Aeternitas::CleanupStaleLocksJob` and `Aeternitas::CleanupOldMetricsJob` to provide a clear, easy way to schedule necessary database cleanup.
27
+ - Test Mode: Added `Aeternitas::Test.test_mode`, which sets all cooldowns, retry delays, and sleep durations to zero to simplify writing tests.
27
28
 
28
29
  ### Removed
29
30
  - Removed direct gem dependencies on `sidekiq`, `sidekiq-unique-jobs`, `redis`, `connection_pool`, and `tabstabs`.
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -220,6 +220,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
220
220
 
221
221
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
222
222
 
223
+ ### Testing
224
+
225
+ Æternitas provides a test mode to help write tests. When enabled, all cooldowns, retry delays, and sleep durations are set to zero. This prevents your test suite from having to wait for scheduled delays.
226
+
227
+ To enable test mode for a specific block of code, use the `Aeternitas::Test.test_mode` helper:
228
+
229
+ ```ruby
230
+ Aeternitas::Test.test_mode do
231
+ # ...
232
+ end
233
+ ```
234
+
235
+ This ensures that test mode is enabled only for the duration of the block and is automatically disabled afterward.
236
+
223
237
  ## Contributing
224
238
 
225
239
  Bug reports and spec backed pull requests are welcome on GitHub at https://github.com/Dietech-Group/aeternitas. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Rakefile CHANGED
File without changes
data/aeternitas.gemspec CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -35,7 +35,7 @@ module Aeternitas
35
35
  # @return [Aeternitas::Guard] Creates a new Instance
36
36
  def initialize(id, cooldown, timeout = 10.minutes)
37
37
  @id = id
38
- @cooldown = cooldown
38
+ @cooldown = Aeternitas.test_mode? ? 0.seconds : cooldown
39
39
  @timeout = timeout
40
40
  @token = SecureRandom.hex(10)
41
41
  end
@@ -134,6 +134,7 @@ module Aeternitas
134
134
  # @param [Time] sleep_timeout for how long will the guard sleep
135
135
  # @param [String] msg hint why the guard sleeps
136
136
  def sleep(sleep_timeout, msg = nil)
137
+ sleep_timeout = Time.now if Aeternitas.test_mode?
137
138
  Aeternitas::GuardLock.transaction do
138
139
  lock = Aeternitas::GuardLock.where(lock_key: @id).lock.first_or_initialize
139
140
 
File without changes
File without changes
File without changes
File without changes
@@ -56,9 +56,10 @@ module Aeternitas
56
56
  meta_data.enqueue!
57
57
 
58
58
  if pollable_config.sleep_on_guard_locked
59
- if base_delay > 0
59
+ delay = Aeternitas.test_mode? ? 0 : base_delay
60
+ if delay > 0
60
61
  ActiveJob::Base.logger.warn "[Aeternitas::PollJob] Guard locked for #{arguments.first}. Sleep for #{base_delay.round(2)}s."
61
- sleep(base_delay)
62
+ sleep(delay)
62
63
  end
63
64
  retry_job
64
65
  else
@@ -78,17 +79,20 @@ module Aeternitas
78
79
  jitter = rand(0.0..2.0)
79
80
  total_wait = base_delay + stagger_delay + jitter
80
81
 
81
- if total_wait > 0
82
- retry_job(wait: total_wait.seconds)
82
+ if total_wait > 0 || Aeternitas.test_mode?
83
+ wait_time = Aeternitas.test_mode? ? 0.seconds : total_wait.seconds
84
+ retry_job(wait: wait_time)
83
85
  ActiveJob::Base.logger.info "[Aeternitas::PollJob] Guard locked for #{arguments.first}. Retry in #{total_wait.round(2)}s."
84
86
  else
85
87
  # GuardLock expired, retry with minimal delay
86
- retry_job(wait: jitter.seconds)
88
+ wait_time = Aeternitas.test_mode? ? 0.seconds : jitter.seconds
89
+ retry_job(wait: wait_time)
87
90
  end
88
91
  end
89
92
  end
90
93
 
91
94
  def self.execution_wait_time(executions)
95
+ return 0.seconds if Aeternitas.test_mode?
92
96
  wait_index = executions - 1
93
97
  RETRY_DELAYS[wait_index] || RETRY_DELAYS.last
94
98
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ module Aeternitas
2
+ # Provides test helpers for aeternitas
3
+ module Test
4
+ # Executes a block of code in test mode; all cooldowns and wait times are set to 0.
5
+ def self.test_mode
6
+ original_mode = Aeternitas.test_mode?
7
+ Aeternitas.test_mode = true
8
+ yield
9
+ ensure
10
+ Aeternitas.test_mode = original_mode
11
+ end
12
+ end
13
+ end
File without changes
@@ -1,3 +1,3 @@
1
1
  module Aeternitas
2
- VERSION = "2.0.0.rc1"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/aeternitas.rb CHANGED
@@ -17,6 +17,7 @@ require "aeternitas/aeternitas_job"
17
17
  require "aeternitas/poll_job"
18
18
  require "aeternitas/cleanup_stale_locks_job"
19
19
  require "aeternitas/cleanup_old_metrics_job"
20
+ require "aeternitas/test"
20
21
 
21
22
  # Aeternitas
22
23
  module Aeternitas
@@ -33,6 +34,18 @@ module Aeternitas
33
34
  yield(config)
34
35
  end
35
36
 
37
+ # Returns true if aeternitas is in test mode.
38
+ # @return [Boolean]
39
+ def self.test_mode?
40
+ @test_mode == true
41
+ end
42
+
43
+ # Sets the test mode.
44
+ # @param [Boolean] value
45
+ def self.test_mode=(value)
46
+ @test_mode = value
47
+ end
48
+
36
49
  # Enqueues all active pollables for which next polling is lower than the current time
37
50
  def self.enqueue_due_pollables
38
51
  Aeternitas::PollableMetaData.due.find_each do |pollable_meta_data|
File without changes
File without changes
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aeternitas
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Prilop
8
8
  - Max Kießling
9
9
  - Louis Franzke
10
+ autorequire:
10
11
  bindir: exe
11
12
  cert_chain: []
12
- date: 1980-01-02 00:00:00.000000000 Z
13
+ date: 2025-08-11 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: activerecord
@@ -177,6 +178,7 @@ files:
177
178
  - lib/aeternitas/source.rb
178
179
  - lib/aeternitas/storage_adapter.rb
179
180
  - lib/aeternitas/storage_adapter/file.rb
181
+ - lib/aeternitas/test.rb
180
182
  - lib/aeternitas/unique_job_lock.rb
181
183
  - lib/aeternitas/version.rb
182
184
  - lib/generators/aeternitas/install_generator.rb
@@ -186,6 +188,7 @@ homepage: https://github.com/Dietech-Group/aeternitas
186
188
  licenses:
187
189
  - MIT
188
190
  metadata: {}
191
+ post_install_message:
189
192
  rdoc_options: []
190
193
  require_paths:
191
194
  - lib
@@ -200,7 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
203
  - !ruby/object:Gem::Version
201
204
  version: '0'
202
205
  requirements: []
203
- rubygems_version: 3.6.9
206
+ rubygems_version: 3.4.19
207
+ signing_key:
204
208
  specification_version: 4
205
209
  summary: æternitas - version 2
206
210
  test_files: []