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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -2
- data/lib/belated/queue.rb +13 -4
- data/lib/belated/version.rb +1 -1
- data/lib/belated.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e61b9cff8c5b664a99f10ce08629e22f5e5439d1f77a50c13568b0c3e90efc61
|
|
4
|
+
data.tar.gz: 84816d001fe4769645181d4baf6868cd89cf06b4812bd710e39bd5a735d04b2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
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
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
data/lib/belated/version.rb
CHANGED
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.
|
|
146
|
+
@@queue.find(job_id)
|
|
146
147
|
end
|
|
147
148
|
|
|
148
149
|
def delete(job_id)
|
|
149
150
|
job = find(job_id)
|
|
150
|
-
@@queue.
|
|
151
|
+
@@queue.delete_job(job)
|
|
151
152
|
end
|
|
152
153
|
|
|
153
154
|
def kill_and_clear_queue!
|