activejob-status 1.0.1 → 1.0.2

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: 843334651f7e39f88ff267202ef1d7bbe239705be4dd5507e97b5c1dcdcd79b6
4
- data.tar.gz: 285ec915bd5eddbd58f83ef557beaf7798a59c9def6b2a7437af1d4a26e9ed58
3
+ metadata.gz: 42019a7ba3be192f9ced4e1edf6498fb81e26a61ffdbce26a488c13518a08595
4
+ data.tar.gz: 8587b93b5aa1f16d77a7649efa3d9e4ef3c6cfe9c90642e37e1a662b20731397
5
5
  SHA512:
6
- metadata.gz: 2d56a7a5b689688deef228d0ec8e7a6ebd68188bf45a9881da5adeddcb7fa2f6ec8baebe7821208c75140015b318b5cb01e23496dd23a7a1baef367b3111f69e
7
- data.tar.gz: 35bb63ac0aac832ed79ce3437731b944a3307193ecffdc502d85c2b9b00cdba0769eac511502411b6f7fa81920d621fd624e9b2f4fc3f8a1dbce970910385b8b
6
+ metadata.gz: bc6ddddeb61c00b4f6ccfe2355b2c4d3f9409362bbd67637169b0ed3b31e2ffc1d33d4643370317f34089870d3e033cc1ad24b6275d45d1537e30893781a5b76
7
+ data.tar.gz: 828dad588548826ec64114ced09b8c2ba784429fe8fab1496520aa1042a90cadf80fa0a7fee4b7565b432c2602c4d9bab5e5d5c30962bce211e8416cf95943b2
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
@@ -324,7 +342,7 @@ class MyJob < ActiveJob::Base
324
342
  end
325
343
  ```
326
344
 
327
- ## ActiveJob::Status and exceptions
345
+ ### ActiveJob::Status and exceptions
328
346
 
329
347
  Internally, ActiveJob::Status uses `ActiveSupport#rescue_from` to catch every `Exception` to apply the `failed` status
330
348
  before throwing the exception again.
@@ -384,6 +402,40 @@ class MyJob < ApplicationJob
384
402
  end
385
403
  ```
386
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
+
387
439
  ## Contributing
388
440
 
389
441
  1. Don't hesitate to submit your feature/idea/fix in [issues](https://github.com/inkstak/activejob-status)
@@ -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.1"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
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.1
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: 2024-01-12 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
@@ -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: []