belated 0.8.1 → 0.8.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: e9ffd4fd7fb145286210861d0b2977e20ec4ed28cf776d753b887c6b8cfe384d
4
- data.tar.gz: e9b006476fa67f3acdcae7a8dfff4da8275f7af4e4ecbada93b462f803fab4e7
3
+ metadata.gz: e61b9cff8c5b664a99f10ce08629e22f5e5439d1f77a50c13568b0c3e90efc61
4
+ data.tar.gz: 84816d001fe4769645181d4baf6868cd89cf06b4812bd710e39bd5a735d04b2b
5
5
  SHA512:
6
- metadata.gz: a1dd51345d62775d2920abf015e804c8cb85c01155e9df75d59e2282d13c892270e0346b661c7896c226862f808d584157c898aa2e6b6a7247f877447842307b
7
- data.tar.gz: 57a1cd7805029a009d2d0b7495eba264325813868c0c3a30984fc6a3b4bb8fcdd400257f1d31ce8277d17848f36c61e19d223e15f429161dcd5d190258809151
6
+ metadata.gz: dc977e1a7806efc5efd79844881162f235ced10abb4f50018f6a2d29b92bf3f18b3bc4b9409e72179a336b091fa0638de7b8057aff61884c9818fff66cccf416
7
+ data.tar.gz: c9852a96a7c50ffc163bb0dd6891133f77f883a87cbd30bab5f3c51b512674f26dded61e50e3dfb5694b464afd5ef6b3410e12fccd95d3ba319651045b8ce3e1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.8.2] - 2021-09-09
4
+ - Fixed a bug where the adapter was not defined when loading jobs from the PStore file.
5
+
3
6
  ## [0.8.1] - 2021-09-09
4
7
  - Now you can delete jobs from the future jobs queue. This is useful if you want to delete a job that is scheduled for a future date.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- belated (0.8.1)
4
+ belated (0.8.2)
5
5
  drb
6
6
  dry-configurable
7
7
  pstore
data/README.md CHANGED
@@ -78,10 +78,14 @@ You can also fetch jobs from the future jobs queue:
78
78
 
79
79
  ```ruby
80
80
  job = client.perform_belated(proc { 0 / 0 }, at: Time.now + 5 * 60)
81
- Belated.find job.id # Find the job if it's in the future queue
81
+ job = Belated.find job.id # Find the job if it's in the future queue
82
82
  # Oh no, that job looks a bit weird!
83
83
  # Let's delete it:
84
- Belated.delete job.id
84
+ client.perform_belated(
85
+ Belated.delete job.id
86
+ )
87
+ # Yeah... currently you have to send the command through the client like this as a job. :/
88
+ # Maybe the client should handle the deletion?
85
89
  ```
86
90
 
87
91
  Belated runs on localhost, port 8788 by default, but the port is configurable, see below.
data/lib/belated/queue.rb CHANGED
@@ -99,10 +99,13 @@ class Belated
99
99
  true
100
100
  end
101
101
 
102
- private
103
-
104
- def proc_or_shutdown?(job)
105
- job.is_a?(Symbol) || job.job.instance_of?(Proc)
102
+ def find(job_id)
103
+ job = nil
104
+ future_jobs_db.transaction(true) do
105
+ job = future_jobs_db[job_id]
106
+ end
107
+ job = future_jobs.find { |j| j.id == job_id } if job.nil?
108
+ job
106
109
  end
107
110
 
108
111
  def delete_job(job)
@@ -112,6 +115,12 @@ class Belated
112
115
  end
113
116
  end
114
117
 
118
+ private
119
+
120
+ def proc_or_shutdown?(job)
121
+ job.is_a?(Symbol) || job.job.instance_of?(Proc)
122
+ end
123
+
115
124
  def insert_into_future_jobs_db(job)
116
125
  future_jobs_db.transaction do
117
126
  future_jobs_db[job.id] = job
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Belated
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
  end
data/lib/belated.rb CHANGED
@@ -89,6 +89,7 @@ class Belated
89
89
  require File.expand_path("#{Belated.config.rails_path}/config/environment.rb")
90
90
  require 'rails/all'
91
91
  require 'belated/rails'
92
+ require 'active_job/queue_adapters/belated_adapter'
92
93
  end
93
94
 
94
95
  def rails?
@@ -142,12 +143,12 @@ class Belated
142
143
 
143
144
  class << self
144
145
  def find(job_id)
145
- @@queue.future_jobs.find { |job| job.id == job_id }
146
+ @@queue.find(job_id)
146
147
  end
147
148
 
148
149
  def delete(job_id)
149
150
  job = find(job_id)
150
- @@queue.future_jobs.delete(job)
151
+ @@queue.delete_job(job)
151
152
  end
152
153
 
153
154
  def kill_and_clear_queue!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen