belated 0.5.4 → 0.5.5
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/.rubocop.yml +0 -3
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +7 -1
- data/README.md +4 -1
- data/belated.gemspec +1 -0
- data/lib/belated.rb +7 -7
- data/lib/belated/job_wrapper.rb +5 -0
- data/lib/belated/queue.rb +5 -3
- data/lib/belated/version.rb +1 -1
- data/lib/belated/worker.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 94a7f0ce2c6f7c80dfe5b8410c72dac95dbc709937361b36aa7eaeea091d8cfb
|
|
4
|
+
data.tar.gz: da41ab683e0a2729b1dc1e7228592e91a0d259cc46bbaf6ef4a2186abb379330
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cacbed28173905bf3fd5489bb8797abecfe4402096cea5d068dcec5a3bf27d9d5c1d048c7d9cc159aedef9cda981a038f4177d6ccd3648c87752d2bedb94390d
|
|
7
|
+
data.tar.gz: f92f505a4d8a53c13b4411ae611d5584377f09b31f8e33f9f39a1daf77b3684b977e3c01a472a654c4c07251a1e0aba6fc2f9953eb7383ef1c15fd7be2385e33
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
-
## [0.5.
|
|
3
|
+
## [0.5.5] - 2021-08-15
|
|
4
|
+
|
|
5
|
+
- Use SortedSet for future jobs, to avoid having to go through the whole list every few seconds.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## [0.5.4] - 2021-08-13
|
|
4
9
|
|
|
5
10
|
- Client was using 100% CPU when it had no connection. (on $5 Digital Ocean droplet) Should be fixed now.
|
|
6
11
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
belated (0.5.
|
|
4
|
+
belated (0.5.5)
|
|
5
5
|
drb
|
|
6
6
|
dry-configurable
|
|
7
|
+
sorted_set
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
@@ -135,6 +136,7 @@ GEM
|
|
|
135
136
|
thor (~> 1.0)
|
|
136
137
|
rainbow (3.0.0)
|
|
137
138
|
rake (13.0.6)
|
|
139
|
+
rbtree (0.4.4)
|
|
138
140
|
regexp_parser (2.1.1)
|
|
139
141
|
rexml (3.2.5)
|
|
140
142
|
rspec (3.10.0)
|
|
@@ -173,6 +175,10 @@ GEM
|
|
|
173
175
|
rubocop (>= 1.7.0, < 2.0)
|
|
174
176
|
rubocop-ast (>= 0.4.0)
|
|
175
177
|
ruby-progressbar (1.11.0)
|
|
178
|
+
set (1.0.1)
|
|
179
|
+
sorted_set (1.0.3)
|
|
180
|
+
rbtree
|
|
181
|
+
set (~> 1.0)
|
|
176
182
|
sprockets (4.0.2)
|
|
177
183
|
concurrent-ruby (~> 1.0)
|
|
178
184
|
rack (> 1, < 3)
|
data/README.md
CHANGED
|
@@ -16,8 +16,10 @@ Can be used with or without Rails.
|
|
|
16
16
|
|
|
17
17
|
TODO LIST:
|
|
18
18
|
|
|
19
|
+
- Use GDBM for queeue storage? That way could maybe get rid of YAML dumping and make things a bit safer.
|
|
20
|
+
- Rescue `DRb::DRbRemoteError` when shutting down, might not need to if using GDBM?
|
|
19
21
|
- Don't use class instance variables.
|
|
20
|
-
- Make port configurable.
|
|
22
|
+
- Make DRb port configurable.
|
|
21
23
|
- Don't hardcode timezone.
|
|
22
24
|
- Add some checks to the client for proper jobs.
|
|
23
25
|
- Have multiple queues?
|
|
@@ -27,6 +29,7 @@ TODO LIST:
|
|
|
27
29
|
- Do some performance testing.
|
|
28
30
|
- Deploy a Rails app to production that is using Belated
|
|
29
31
|
and mention it in the readme. (Capistrano support?)
|
|
32
|
+
([Wasurechatta](wasurechatta.com))
|
|
30
33
|
- Add a section telling people to use Sidekiq if they can
|
|
31
34
|
|
|
32
35
|
## Installation
|
data/belated.gemspec
CHANGED
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
# Uncomment to register a new dependency of your gem
|
|
34
34
|
spec.add_dependency 'drb'
|
|
35
35
|
spec.add_dependency 'dry-configurable'
|
|
36
|
+
spec.add_dependency 'sorted_set'
|
|
36
37
|
spec.add_development_dependency 'byebug'
|
|
37
38
|
|
|
38
39
|
# For more information and examples about making a new gem, checkout our
|
data/lib/belated.rb
CHANGED
|
@@ -92,15 +92,15 @@ class Belated
|
|
|
92
92
|
log 'starting future jobs thread'
|
|
93
93
|
loop do
|
|
94
94
|
sleep 0.1
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
job = @@queue.future_jobs.at(0)
|
|
96
|
+
if job.nil?
|
|
97
|
+
sleep 5
|
|
97
98
|
next
|
|
98
99
|
end
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
end
|
|
100
|
+
|
|
101
|
+
if job.at <= Time.now.utc
|
|
102
|
+
log "Deleting #{@@queue.future_jobs.delete(job)} from future jobs"
|
|
103
|
+
@@queue.push(job)
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
data/lib/belated/job_wrapper.rb
CHANGED
|
@@ -3,6 +3,7 @@ require_relative 'logging'
|
|
|
3
3
|
|
|
4
4
|
class Belated
|
|
5
5
|
class JobWrapper
|
|
6
|
+
include Comparable
|
|
6
7
|
include Logging
|
|
7
8
|
attr_accessor :retries, :max_retries, :id, :job, :at
|
|
8
9
|
|
|
@@ -14,6 +15,10 @@ class Belated
|
|
|
14
15
|
self.at = at
|
|
15
16
|
end
|
|
16
17
|
|
|
18
|
+
def <=>(another)
|
|
19
|
+
at <=> another.at
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
# rubocop:disable Lint/RescueException
|
|
18
23
|
def perform
|
|
19
24
|
if job.respond_to?(:call)
|
data/lib/belated/queue.rb
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
require 'belated/job'
|
|
4
4
|
require 'belated/logging'
|
|
5
5
|
require 'belated/job_wrapper'
|
|
6
|
+
require 'sorted_set'
|
|
7
|
+
|
|
6
8
|
class Belated
|
|
7
9
|
class Queue
|
|
8
10
|
include Logging
|
|
@@ -10,13 +12,13 @@ class Belated
|
|
|
10
12
|
|
|
11
13
|
FILE_NAME = 'belated_dump'
|
|
12
14
|
|
|
13
|
-
def initialize(queue: Thread::Queue.new, future_jobs:
|
|
15
|
+
def initialize(queue: Thread::Queue.new, future_jobs: SortedSet.new)
|
|
14
16
|
@queue = queue
|
|
15
17
|
self.future_jobs = future_jobs
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def push(job)
|
|
19
|
-
if job
|
|
21
|
+
if job.is_a?(Symbol) || job.at.nil? ||
|
|
20
22
|
job.at <= Time.now.utc
|
|
21
23
|
@queue.push(job)
|
|
22
24
|
else
|
|
@@ -79,7 +81,7 @@ class Belated
|
|
|
79
81
|
private
|
|
80
82
|
|
|
81
83
|
def proc_or_shutdown?(job)
|
|
82
|
-
job.job.instance_of?(Proc) || job
|
|
84
|
+
job.job.instance_of?(Proc) || job.is_a?(Symbol)
|
|
83
85
|
end
|
|
84
86
|
end
|
|
85
87
|
end
|
data/lib/belated/version.rb
CHANGED
data/lib/belated/worker.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: belated
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sampo Kuokkanen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-08-
|
|
11
|
+
date: 2021-08-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: drb
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: sorted_set
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: byebug
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|