belated 0.5.0 → 0.5.4

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: f63b50cb41ebaa52127b51ef4a38f70467bd6527d16efb6869965d5b3c9d3bab
4
- data.tar.gz: 03ffefae27d2a9f76854b18abad3e2bd46fe3012e987008b5514fd86f699a5ba
3
+ metadata.gz: 918d89e2f82daa2abdd57976ca18edbf994dcd4c92b4480bf139983f2a51e26d
4
+ data.tar.gz: 1c684c38e41ba507d048463c4e287802fed0b067f9263702ea9fb3bbc4bfb22c
5
5
  SHA512:
6
- metadata.gz: 619b6fc1269319b827dcfe48cc84caa951b00bea7fcd4086ebb73ab4ab72c431a3d2b02c2032e02e305913d2613c6b1f67be9c5f1edbd3a2432a0fdec3667c57
7
- data.tar.gz: ccbed4ecf9df5627e28929c66287700160f3b9a31dd40b107f186eb1a8fe917cfc80edaa7b756743440d4c643ffa60b93cb06f463b06541929a62639b0fae1fb
6
+ metadata.gz: 7db6cbabae254f0152bd4a4367de72ad18085c58923dcb0420e20b94dbab0fb713fc00c54031bbe6788363a626d0a2ad315e6690b6cba0849aade14a406cb2f8
7
+ data.tar.gz: '0578bcaadeac30fa0d4cea61862de5927ca8624364fcb954a5a2f7f57c3cc1871c4fc99cb0730505aeb7e1f81ee0eb24327f5f48ef5aae4bf85fc5d5647baef3'
data/.rubocop.yml CHANGED
@@ -1,3 +1,4 @@
1
+ require: rubocop-performance
1
2
  AllCops:
2
3
  TargetRubyVersion: 2.7
3
4
  NewCops: enable
data/CHANGELOG.md CHANGED
@@ -1,7 +1,21 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.4] - 2021-08-14
3
4
 
4
- ## [0.5.0] - 2021-08-07
5
+ - Client was using 100% CPU when it had no connection. (on $5 Digital Ocean droplet) Should be fixed now.
6
+
7
+ ## [0.5.3] - 2021-08-13
8
+
9
+ - A bit less looping - better performance.
10
+ ## [0.5.2] - 2021-08-13
11
+
12
+ - An error with shutdown handling was fixed.
13
+
14
+ ## [0.5.1] - 2021-08-12
15
+
16
+ - Requiring byebug in bin file. 😮
17
+
18
+ ## [0.5.0] - 2021-08-011
5
19
 
6
20
  - Job retries! The jobs now have ids, so you can follow the job and it's retries from the log.
7
21
  - Quite a lot has changed internally, so if you were not using the Belated::Queue class to enqueue your jobs, you will need to update your code.
data/Gemfile CHANGED
@@ -9,10 +9,10 @@ gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'rspec', '~> 3.0'
11
11
 
12
- gem 'rubocop', '~> 1.7'
13
-
14
12
  gem 'database_cleaner-active_record'
15
13
  gem 'rails', '>= 6.1.3'
16
14
  gem 'rspec-rails'
15
+ gem 'rubocop', '~> 1.7'
16
+ gem 'rubocop-performance', require: false
17
17
  gem 'sqlite3'
18
18
  gem 'stackprof'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- belated (0.5.0)
4
+ belated (0.5.4)
5
5
  drb
6
6
  dry-configurable
7
7
 
@@ -169,6 +169,9 @@ GEM
169
169
  unicode-display_width (>= 1.4.0, < 3.0)
170
170
  rubocop-ast (1.7.0)
171
171
  parser (>= 3.0.1.1)
172
+ rubocop-performance (1.11.4)
173
+ rubocop (>= 1.7.0, < 2.0)
174
+ rubocop-ast (>= 0.4.0)
172
175
  ruby-progressbar (1.11.0)
173
176
  sprockets (4.0.2)
174
177
  concurrent-ruby (~> 1.0)
@@ -200,8 +203,9 @@ DEPENDENCIES
200
203
  rspec (~> 3.0)
201
204
  rspec-rails
202
205
  rubocop (~> 1.7)
206
+ rubocop-performance
203
207
  sqlite3
204
208
  stackprof
205
209
 
206
210
  BUNDLED WITH
207
- 2.2.17
211
+ 2.2.22
data/README.md CHANGED
@@ -136,9 +136,15 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
136
136
 
137
137
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
138
138
 
139
+
140
+ # Possible problems
141
+
142
+ If you have the port 8788 already in use, you can check the ports in use in Linux with the following command:
143
+
144
+ $ sudo lsof -i -P -n | grep LISTEN
139
145
  ## Contributing
140
146
 
141
- Bug reports and pull requests are welcome on GitHub at https://github.com/sampokuokkanen/belated. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sampokuokkanen/belated/blob/master/CODE_OF_CONDUCT.md).
147
+ Bug reports, questions and pull requests are welcome on GitHub at https://github.com/sampokuokkanen/belated. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sampokuokkanen/belated/blob/master/CODE_OF_CONDUCT.md).
142
148
 
143
149
  ## License
144
150
 
data/bin/belated CHANGED
@@ -5,7 +5,6 @@ $TESTING = false
5
5
  $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
6
6
  require 'belated'
7
7
  require 'optparse'
8
- require 'byebug'
9
8
 
10
9
  OptionParser.new { |opts|
11
10
  opts.banner = 'Usage: belated [options]'
data/lib/belated.rb CHANGED
@@ -91,13 +91,17 @@ class Belated
91
91
  def enqueue_future_jobs
92
92
  log 'starting future jobs thread'
93
93
  loop do
94
+ sleep 0.1
95
+ if @@queue.future_jobs.empty?
96
+ sleep 1
97
+ next
98
+ end
94
99
  @@queue.future_jobs.each_with_index do |job, i|
95
100
  if job.at <= Time.now.utc
96
101
  log "Deleting #{@@queue.future_jobs.delete_at(i)} from future jobs"
97
102
  @@queue.push(job)
98
103
  end
99
104
  end
100
- sleep 0.01
101
105
  end
102
106
  end
103
107
 
@@ -26,6 +26,12 @@ class Belated
26
26
  def start_banker_thread
27
27
  self.banker_thread = Thread.new do
28
28
  loop do
29
+ sleep 0.01
30
+ unless drb_connected?
31
+ sleep(10)
32
+ next
33
+ end
34
+
29
35
  job = bank.pop
30
36
 
31
37
  perform(job)
@@ -50,9 +56,16 @@ class Belated
50
56
  rescue DRb::DRbConnError
51
57
  bank.push(job_wrapper)
52
58
  start_banker_thread if banker_thread.nil?
53
- banker_thread.wakeup if banker_thread.status == 'sleep'
54
59
  end
55
60
  alias perform_belated perform
56
61
  alias perform_later perform
62
+
63
+ private
64
+
65
+ def drb_connected?
66
+ queue.connected?
67
+ rescue StandardError
68
+ false
69
+ end
57
70
  end
58
71
  end
data/lib/belated/queue.rb CHANGED
@@ -16,7 +16,8 @@ class Belated
16
16
  end
17
17
 
18
18
  def push(job)
19
- if job.at.nil? || job.at <= Time.now.utc
19
+ if job == :shutdown || job.at.nil? ||
20
+ job.at <= Time.now.utc
20
21
  @queue.push(job)
21
22
  else
22
23
  @future_jobs << job
@@ -71,6 +72,10 @@ class Belated
71
72
  pp File.open(FILE_NAME, 'wb') { |f| f.write(YAML.dump(class_array)) }
72
73
  end
73
74
 
75
+ def connected?
76
+ true
77
+ end
78
+
74
79
  private
75
80
 
76
81
  def proc_or_shutdown?(job)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Belated
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.4'
5
5
  end
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.0
4
+ version: 0.5.4
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 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: drb
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.2.15
112
+ rubygems_version: 3.2.22
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Run background jobs with Belated and dRuby!