belated 0.4.3 → 0.4.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: 598cfda479ae3ec79564557a4f111ff5600c255bdf3cc8b3e03194b0b0b6ce86
4
- data.tar.gz: f6b07150c218bf9754f5d40625e7e5d26673f87bf4d8a1baa4ef87814edbbc09
3
+ metadata.gz: b946c5167a28af0cd73bad436d52c47ad19af699d88bd8a20c592b8fb2327ea1
4
+ data.tar.gz: da03cfda6b0c4ec8b9a9a7ef4cb52747294f3b582633ad023cc98aa5e88c697f
5
5
  SHA512:
6
- metadata.gz: 43ab001fcc721b6750ec2c7d3ee00f32ab58ff9909268bb9dda92d7096a5cca85782fbd8f3502295cc07086ac6ef18c056124f55ef4a706b607d2aab3c667ef8
7
- data.tar.gz: c83cec5063743c8ed84a28a1b5995b7b3d7deeade1f6f352d81d1dca5b1531231dc46678f14e1ad6795662d8105dfc957ca81f7868996b310bc8b4128132e0c9
6
+ metadata.gz: 5add925bbaca101aef9a35c8d4ae6cc544b736ebbbcbae4e6603faf0e42a0a248bd04844b0af8fa6dceb32f021948c105bf18031fd0c97d12cfc85ac9d9cde3f
7
+ data.tar.gz: 13ac76b9f2b956e9b0b363d16ec3e615365ee39132fe788022c11c2ff90ed7fa9234c403903ac268efae0c63a51afbe6bc9893eb95cd8bbdf5d20b75e6a85aaf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+
4
+ ## [0.4.4] - 2021-08-07
5
+
6
+ - Now if you pass something with a syntax error in it as a job, it should not bring down the whole app!
7
+
3
8
  ## [0.4.3] - 2021-08-06
4
9
 
5
10
  - Client now starts the banker thread to execute jobs that were enqueued when there was no connection to Belated only if necessary.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- belated (0.4.3)
4
+ belated (0.4.4)
5
5
  drb
6
6
  dry-configurable
7
7
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![CodeFactor](https://www.codefactor.io/repository/github/sampokuokkanen/belated/badge)](https://www.codefactor.io/repository/github/sampokuokkanen/belated) [![Gem Version](https://badge.fury.io/rb/belated.svg)](https://badge.fury.io/rb/belated)
4
4
 
5
- This is Belated, a new Ruby backend job library! It supports running procs and classes in the background. To deal with restarts, it uses YAML to load the queue into a file, which it then calls at startup to find the previous jobs.
5
+ This is Belated, a new Ruby backend job library! It supports running procs, lambdas and classes in the background. To deal with restarts, it uses YAML to load the queue into a file, which it then calls at startup to find the previous jobs. There is no way in Ruby to save procs or lambdas to a file, so they are discarded when the process restarts.
6
6
 
7
7
  Belated uses the Ruby Queue class, so it's First In, First Out (FIFO).
8
8
 
@@ -14,14 +14,14 @@ Can be used with or without Rails.
14
14
 
15
15
  TODO LIST:
16
16
 
17
+ - Add retries for jobs
17
18
  - Add some checks to the client for proper jobs.
18
- - Don't crash on errors (Partially done)
19
19
  - Have multiple queues?
20
20
  - Maybe support ActiveJob?
21
21
  - Have a web UI
22
22
  - Do some performance testing
23
23
  - Deploy a Rails app to production that is using Belated
24
- and mention it in the readme.
24
+ and mention it in the readme. (Capistrano support?)
25
25
  - Add a section telling people to use Sidekiq if they can
26
26
 
27
27
  ## Installation
@@ -90,6 +90,7 @@ and you can use the client!
90
90
  Call
91
91
 
92
92
  ```ruby
93
+ job = proc { 2 / 1 }
93
94
  client.perform_belated(job)
94
95
  ```
95
96
 
@@ -101,7 +102,7 @@ If you don't want the job to run right away, you can also pass it a keyword para
101
102
  client.perform_belated(job, Time.now + 1.month)
102
103
  ```
103
104
 
104
- Note that you probably want to memoize the client, as it always creates a 'banker thread' now if you have no connection. Maybe even use it as a global!(`$client`)
105
+ Note that you probably want to memoize the client, as it always creates a 'banker thread' now if you have no connection and there is the overhead of connecting to dRuby. Maybe even use it as a global!(`$client`)
105
106
 
106
107
  # Settings
107
108
 
data/lib/belated.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'belated/logging'
3
4
  require_relative 'belated/version'
4
5
  require_relative 'belated/worker'
5
- require_relative 'belated/logging'
6
+ require 'belated/client'
7
+ require 'belated/queue'
6
8
  require 'drb'
7
- require 'yaml'
8
- require 'singleton'
9
9
  require 'dry-configurable'
10
- require 'belated/client'
11
10
  require 'logger'
12
- require 'belated/queue'
11
+ require 'singleton'
12
+ require 'yaml'
13
13
 
14
14
  # Belated is a pure Ruby job backend.
15
15
  # It has limited functionality, as it only accepts
@@ -64,7 +64,11 @@ class Belated
64
64
  @@queue.push(:shutdown)
65
65
  end
66
66
  Thread.new { stop_workers }
67
- sleep 0.1 until @@queue.empty? || $TESTING
67
+ # Max 30 seconds to shutdown
68
+ timeout = 0
69
+ until (timeout += 0.1) >= 30 || @@queue.empty? || $TESTING
70
+ sleep 0.1
71
+ end
68
72
  exit
69
73
  end
70
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Belated
4
- VERSION = '0.4.3'
4
+ VERSION = '0.4.4'
5
5
  end
@@ -22,14 +22,21 @@ class Belated
22
22
  end
23
23
  end
24
24
 
25
+ # rubocop:disable Lint/RescueException
25
26
  def call_job(job)
26
27
  if job.respond_to?(:call)
27
28
  job.call
28
29
  else
29
30
  job.perform
30
31
  end
31
- rescue StandardError => e
32
- e.inspect
32
+ rescue Exception => e
33
+ case e.class
34
+ when Interrupt, SignalException
35
+ raise e
36
+ else
37
+ e.inspect
38
+ end
33
39
  end
40
+ # rubocop:enable Lint/RescueException
34
41
  end
35
42
  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.4.3
4
+ version: 0.4.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-06 00:00:00.000000000 Z
11
+ date: 2021-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: drb