activejob-status 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a87cf9049d2e78bf3374c506ba99606dc7770a8e263fc12b1f74b64c7a67fab
4
- data.tar.gz: 2ae8982bdf6e66bf2002e02fe2df89bf8082ed5d765ca3f49864869b516fc14c
3
+ metadata.gz: 42019a7ba3be192f9ced4e1edf6498fb81e26a61ffdbce26a488c13518a08595
4
+ data.tar.gz: 8587b93b5aa1f16d77a7649efa3d9e4ef3c6cfe9c90642e37e1a662b20731397
5
5
  SHA512:
6
- metadata.gz: 894b7c42328e39fc9c822edf12f32cb9d9c0e95b248e08dcdcfa19ad8151c9192561866e23185797cd7e6a21b811cb8c751fb884ed9143f698dcc13c6872f82f
7
- data.tar.gz: 1a7629d6f18764117de7bcb6643baad9f98c76b1ff91b7964cb6aa3b2d6197ebee49bb75cd38c9f9ac1a5dcd7576bf7bf7c0d91b442bda3ed7580d3d54b5aea8
6
+ metadata.gz: bc6ddddeb61c00b4f6ccfe2355b2c4d3f9409362bbd67637169b0ed3b31e2ffc1d33d4643370317f34089870d3e033cc1ad24b6275d45d1537e30893781a5b76
7
+ data.tar.gz: 828dad588548826ec64114ced09b8c2ba784429fe8fab1496520aa1042a90cadf80fa0a7fee4b7565b432c2602c4d9bab5e5d5c30962bce211e8416cf95943b2
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2023 Savater Sebastien
1
+ Copyright (c) 2016-2024 Savater Sebastien
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -8,6 +8,24 @@ Simple monitoring status for ActiveJob, independent of your queuing backend or c
8
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/a7b1ec1d3769e49021fd/maintainability)](https://codeclimate.com/github/inkstak/activejob-status/maintainability)
9
9
  [![Test Coverage](https://api.codeclimate.com/v1/badges/a7b1ec1d3769e49021fd/test_coverage)](https://codeclimate.com/github/inkstak/activejob-status/test_coverage)
10
10
 
11
+ ## Table of contents
12
+
13
+ - [Installation](#installation)
14
+ - [Dependencies](#dependencies)
15
+ - [Configuration](#configuration)
16
+ - [Cache Store](#cache-store)
17
+ - [Select data to store by default](#select-data-to-store-by-default)
18
+ - [Expiration time](#expiration-time)
19
+ - [Throttling](#throttling)
20
+ - [Usage](#usage)
21
+ - [Updating status](#updating-status)
22
+ - [Data stored by default](#data-stored-by-default)
23
+ - [Reading status](#reading-status)
24
+ - [Serializing status to JSON](#serializing-status-to-json)
25
+ - [Setting options per job](#setting-options-per-job)
26
+ - [ActiveJob::Status and exceptions](#activejobstatus-and-exceptions)
27
+ - [[Beta] Batches](#beta-batches)
28
+
11
29
  ## Installation
12
30
 
13
31
  ```bash
@@ -20,12 +38,9 @@ bundle add activejob-status
20
38
 
21
39
  ## Dependencies
22
40
 
23
- In future releases, `ActiveJob::Status` won't support [EOL versions](https://endoflife.date/rails) of `ActiveJob` & `ActiveSupport`.
24
-
25
- * Version `1.x` requires `ActiveSupport >= 6.0`
26
-
27
- If you're still using older Rails version, see [#24](https://github.com/inkstak/activejob-status/issues/24#issuecomment-1436046173).
41
+ ActiveJob::Status 1.x requires `ActiveSupport >= 6.0`
28
42
 
43
+ If you're still using an older version of Rails, see [v0.5.0](https://github.com/inkstak/activejob-status/releases/tag/v0.5.0).
29
44
 
30
45
  ## Configuration
31
46
 
@@ -327,7 +342,7 @@ class MyJob < ActiveJob::Base
327
342
  end
328
343
  ```
329
344
 
330
- ## ActiveJob::Status and exceptions
345
+ ### ActiveJob::Status and exceptions
331
346
 
332
347
  Internally, ActiveJob::Status uses `ActiveSupport#rescue_from` to catch every `Exception` to apply the `failed` status
333
348
  before throwing the exception again.
@@ -387,6 +402,40 @@ class MyJob < ApplicationJob
387
402
  end
388
403
  ```
389
404
 
405
+ ### [Beta] Batches
406
+
407
+ > **Warning** : The Batch API is available on [beta](https://github.com/inkstak/activejob-status/tree/beta):
408
+ >
409
+ > ```bash
410
+ > gem install activejob-status --pre
411
+ > # or
412
+ > bundle add activejob-status --version "~> 1.1.0.beta.0"
413
+ > ```
414
+ >
415
+ > It doesn't provide all features implemented by backends
416
+ > like [Sidekiq](https://github.com/sidekiq/sidekiq/wiki/Batches)
417
+ > or [GoodJob](https://github.com/bensheldon/good_job?tab=readme-ov-file#batches).
418
+ > Moreover, it wasn't designed to support batches with hundreds of jobs (or you might experience performanes issues).
419
+ >
420
+
421
+ ActiveJob::Status provides a naïve implementation of batches:
422
+
423
+ ```ruby
424
+ job_1 = MyJob.perform_later
425
+ job_2 = MyJob.perform_later
426
+
427
+ batch = ActiveJob::Status::Batch.new([job_1, job_2])
428
+ batch.status # => "working"
429
+ ```
430
+
431
+ The batch status is considered:
432
+
433
+ * `queued` if **all** of the jobs are `queued`
434
+ * `failed` if **one** of the jobs is `failed`
435
+ * `completed` if **all** of the jobs are `completed`
436
+ * `working` in all other circumstances
437
+
438
+
390
439
  ## Contributing
391
440
 
392
441
  1. Don't hesitate to submit your feature/idea/fix in [issues](https://github.com/inkstak/activejob-status)
@@ -403,20 +452,20 @@ bundle exec rubocop
403
452
  bundle exec standardrb
404
453
  ```
405
454
 
406
- All of them can be run with:
407
-
455
+ To run RSpec against various version of Rails dependencies:
408
456
  ```bash
409
- bundle exec rake
457
+ bundle exec appraisal install
458
+ bundle exec appraisal rspec
410
459
  ```
411
460
 
412
- To run test suite against various version of Rails dependencies:
461
+ All of them can be run with:
462
+
413
463
  ```bash
414
- bundle exec appraisal install
415
- bundle exec appraisal
464
+ bundle exec rake
416
465
  ```
417
466
 
418
467
  ## License & credits
419
468
 
420
- Please see [LICENSE](https://github.com/inkstak/coverart/blob/main/LICENSE) for further details.
469
+ Please see [LICENSE](https://github.com/inkstak/activejob-status/blob/main/LICENSE) for further details.
421
470
 
422
- Contributors: [./graphs/contributors](https://github.com/inkstak/coverart/graphs/contributors)
471
+ Contributors: [./graphs/contributors](https://github.com/inkstak/activejob-status/graphs/contributors)
@@ -44,7 +44,9 @@ module ActiveJob
44
44
  end
45
45
 
46
46
  def progress
47
- read[:progress].to_f / read[:total].to_f
47
+ read.then do |hash|
48
+ hash[:progress].to_f / hash[:total].to_f
49
+ end
48
50
  end
49
51
 
50
52
  def present?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveJob
4
4
  module Status
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
@@ -54,7 +54,7 @@ module ActiveJob
54
54
  end
55
55
 
56
56
  def store
57
- @@store ||= (defined?(Rails) && Rails.cache)
57
+ @@store ||= (Rails.cache if defined?(Rails))
58
58
  end
59
59
 
60
60
  def get(id)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savater Sebastien
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-03 00:00:00.000000000 Z
10
+ date: 2024-04-18 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activejob
@@ -156,14 +155,14 @@ dependencies:
156
155
  requirements:
157
156
  - - ">="
158
157
  - !ruby/object:Gem::Version
159
- version: '0'
158
+ version: '1.0'
160
159
  type: :development
161
160
  prerelease: false
162
161
  version_requirements: !ruby/object:Gem::Requirement
163
162
  requirements:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
- version: '0'
165
+ version: '1.0'
167
166
  - !ruby/object:Gem::Dependency
168
167
  name: timecop
169
168
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +177,6 @@ dependencies:
178
177
  - - ">="
179
178
  - !ruby/object:Gem::Version
180
179
  version: '0'
181
- description:
182
180
  email: github.60k5k@simplelogin.co
183
181
  executables: []
184
182
  extensions: []
@@ -196,7 +194,6 @@ homepage: https://github.com/inkstak/activejob-status
196
194
  licenses:
197
195
  - MIT
198
196
  metadata: {}
199
- post_install_message:
200
197
  rdoc_options: []
201
198
  require_paths:
202
199
  - lib
@@ -211,8 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
208
  - !ruby/object:Gem::Version
212
209
  version: '0'
213
210
  requirements: []
214
- rubygems_version: 3.1.6
215
- signing_key:
211
+ rubygems_version: 3.6.0.dev
216
212
  specification_version: 4
217
213
  summary: Monitor your jobs
218
214
  test_files: []