pallets 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ede234db1dfe8c744cf11e6e2fde3eb2e982e7764738715acbbad35710422274
4
- data.tar.gz: a55b3a714dcc5db2a294b27ca53724a1236111e08f63078bcef5007bda65532c
3
+ metadata.gz: 715e8a2c758fa925afce7091b931d4ea71b02f548290d4daf73604cdd463de3d
4
+ data.tar.gz: 750fd79e4d8aea7920ac4a019ac410d2ec07b910a1cf70e673a628d1604a90de
5
5
  SHA512:
6
- metadata.gz: 74e23087ba192aeffeb7e167d751bfb6f85de4018fb3c16e992ac6119d7670d60862f41a8e1624817a25944409602e41ee38f13adad7b14a38b185d51142b644
7
- data.tar.gz: 96ae4f2aa4edf5d27d366e7a35f16527e9d390a45794d306acc109b1be335682c8b1e13e7d708d7eb3451eb8b6ed96db37ba724da08abb13d7b84f3468869826
6
+ metadata.gz: f3c7d08ad9b0de820f14ec4e3a3bbce77d5e10e9d6bfd99b58273360ce8dc6eeedec8d139d0f9445082848f5b9587dc67b706e49794746cc3208d6cde3aa9516
7
+ data.tar.gz: '0584d9d3faaebea5c615ee6d9c6dc0397d4e65c04cd80b1722a4cea2794bcf5c61a4762a539a2abf2d21e6a9f52de9a7b8f8e5241615168461bdb674a1465772'
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.10.0] - 2020-08-30
10
+ ### Added
11
+ - configure polling interval for scheduler (#60)
12
+
13
+ ### Changed
14
+ - handle persisting unforseen worker errors more gracefully (#59)
15
+ - add initial wait to scheduler startup (#60)
16
+
9
17
  ## [0.9.0] - 2020-07-05
10
18
  ### Added
11
19
  - limit number of jobs in given up set by number (#56)
@@ -43,7 +43,7 @@ end
43
43
 
44
44
  class Volatile < Pallets::Task
45
45
  def run
46
- raise 'I am ràndomly failing' if [true, false].sample
46
+ raise 'I am randomly failing' if [true, false].sample
47
47
  end
48
48
  end
49
49
 
@@ -63,6 +63,10 @@ module Pallets
63
63
  Pallets.configuration.max_failures = max_failures
64
64
  end
65
65
 
66
+ opts.on('-i', '--scheduler-polling-interval NUM', Integer, 'Seconds between scheduler backend polls') do |scheduler_polling_interval|
67
+ Pallets.configuration.scheduler_polling_interval = scheduler_polling_interval
68
+ end
69
+
66
70
  opts.on('-l', '--failed-job-lifespan NUM', Integer, 'Seconds a job stays in the given up set') do |failed_job_lifespan|
67
71
  Pallets.configuration.failed_job_lifespan = failed_job_lifespan
68
72
  end
@@ -31,6 +31,12 @@ module Pallets
31
31
  # Number of connections to the backend
32
32
  attr_writer :pool_size
33
33
 
34
+ # Number of seconds at which the scheduler checks whether there are jobs
35
+ # due to be (re)processed. Note that this interval is per process; it might
36
+ # require tweaking in case of running multiple Pallets instances, so that
37
+ # the backend is not polled too often
38
+ attr_accessor :scheduler_polling_interval
39
+
34
40
  # Serializer used for jobs
35
41
  attr_accessor :serializer
36
42
 
@@ -52,6 +58,7 @@ module Pallets
52
58
  @failed_job_max_count = 1_000
53
59
  @job_timeout = 1_800 # 30 minutes
54
60
  @max_failures = 3
61
+ @scheduler_polling_interval = 10
55
62
  @serializer = :json
56
63
  @middleware = default_middleware
57
64
  end
@@ -7,7 +7,7 @@ module Pallets
7
7
  end
8
8
 
9
9
  def start
10
- @thread ||= Thread.new { work }
10
+ @thread ||= Thread.new { wait_initial_bit; work }
11
11
  end
12
12
 
13
13
  def shutdown
@@ -40,11 +40,17 @@ module Pallets
40
40
  end
41
41
  end
42
42
 
43
- def wait_a_bit
44
- # Wait for roughly 10 seconds
43
+ def wait_initial_bit
44
+ # Randomly wait a bit before starting working, so that multiple processes
45
+ # will not hit the backend all at once
46
+ wait_a_bit(rand(Pallets.configuration.scheduler_polling_interval))
47
+ end
48
+
49
+ def wait_a_bit(seconds = Pallets.configuration.scheduler_polling_interval)
50
+ # Wait for roughly the configured number of seconds
45
51
  # We don't want to block the entire polling interval, since we want to
46
52
  # deal with shutdowns synchronously and as fast as possible
47
- 10.times do
53
+ seconds.times do
48
54
  break if needs_to_stop?
49
55
  sleep 1
50
56
  end
@@ -1,3 +1,3 @@
1
1
  module Pallets
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -55,6 +55,8 @@ module Pallets
55
55
  rescue => ex
56
56
  Pallets.logger.error "#{ex.class.name}: #{ex.message}"
57
57
  Pallets.logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
58
+ # Do not flood the process in case of persisting unforeseen errors
59
+ sleep 1
58
60
  @manager.replace_worker(self)
59
61
  end
60
62
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pallets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Horak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-05 00:00:00.000000000 Z
11
+ date: 2020-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis