fleiss 0.4.3 → 0.4.4

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: cb419b5311dcda76bb9c1743b08ea56cfee270fbe6f90721347e492b2dfec292
4
- data.tar.gz: 995152a6f0482b04f272ed70ab1426be7fd225eed7c30c80de638e2b56f7e119
3
+ metadata.gz: ee721d0d8b4ceb6a3308ded176bac0cbb64aafe602bf4aacda952d9440cff486
4
+ data.tar.gz: 93f4afd58038d95d24bb75640fc96b613a7eac6a421e18852ade1e25ad9df76b
5
5
  SHA512:
6
- metadata.gz: 9d12678587c252a310e7fac2cc80a420076b229a3cf93458016b572b749d002b652d53ce08cf74b28e75b92f50be6c8aac948d146261a1b113db1fa844827a99
7
- data.tar.gz: '0107013391774abea71a113ac3dc3849c3a08e340ff534d68468629b2e4832798763320e11251ee57ee927c5f4210ed64bf945eedbc57f08086f7415c2fd0a2c'
6
+ metadata.gz: '078d55bb3edf9c2419fbbd7c1906195019e50b356301cb2a4570645b5abae563975f6c0ea6d0632ce039f87c7faddb10b9a21170a0486e06011606a4c4039899'
7
+ data.tar.gz: cbe4badf9b18b68b9e664ed9bd9a0ec2e1021dfe5ea088ae6a404e6938e325f92fffdb1d24ee8c642b103cdf847272fa85ff2e057c120ee01ce6be8a6d78aed1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fleiss (0.4.3)
4
+ fleiss (0.4.4)
5
5
  activejob (>= 6.0)
6
6
  activerecord (>= 6.0)
7
7
  concurrent-ruby
@@ -9,15 +9,15 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activejob (6.1.4)
13
- activesupport (= 6.1.4)
12
+ activejob (6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
14
  globalid (>= 0.3.6)
15
- activemodel (6.1.4)
16
- activesupport (= 6.1.4)
17
- activerecord (6.1.4)
18
- activemodel (= 6.1.4)
19
- activesupport (= 6.1.4)
20
- activesupport (6.1.4)
15
+ activemodel (6.1.4.1)
16
+ activesupport (= 6.1.4.1)
17
+ activerecord (6.1.4.1)
18
+ activemodel (= 6.1.4.1)
19
+ activesupport (= 6.1.4.1)
20
+ activesupport (6.1.4.1)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 1.6, < 2)
23
23
  minitest (>= 5.1)
@@ -26,13 +26,13 @@ GEM
26
26
  ast (2.4.2)
27
27
  concurrent-ruby (1.1.9)
28
28
  diff-lcs (1.4.4)
29
- globalid (0.5.1)
29
+ globalid (0.5.2)
30
30
  activesupport (>= 5.0)
31
31
  i18n (1.8.10)
32
32
  concurrent-ruby (~> 1.0)
33
33
  minitest (5.14.4)
34
34
  mysql2 (0.5.3)
35
- parallel (1.20.1)
35
+ parallel (1.21.0)
36
36
  parser (3.0.2.0)
37
37
  ast (~> 2.4.1)
38
38
  pg (1.2.3)
@@ -53,23 +53,23 @@ GEM
53
53
  diff-lcs (>= 1.2.0, < 2.0)
54
54
  rspec-support (~> 3.10.0)
55
55
  rspec-support (3.10.2)
56
- rubocop (1.18.3)
56
+ rubocop (1.21.0)
57
57
  parallel (~> 1.10)
58
58
  parser (>= 3.0.0.0)
59
59
  rainbow (>= 2.2.2, < 4.0)
60
60
  regexp_parser (>= 1.8, < 3.0)
61
61
  rexml
62
- rubocop-ast (>= 1.7.0, < 2.0)
62
+ rubocop-ast (>= 1.9.1, < 2.0)
63
63
  ruby-progressbar (~> 1.7)
64
64
  unicode-display_width (>= 1.4.0, < 3.0)
65
- rubocop-ast (1.8.0)
65
+ rubocop-ast (1.11.0)
66
66
  parser (>= 3.0.1.1)
67
67
  rubocop-bsm (0.6.0)
68
68
  rubocop (~> 1.0)
69
69
  rubocop-performance
70
70
  rubocop-rake
71
71
  rubocop-rspec
72
- rubocop-performance (1.11.4)
72
+ rubocop-performance (1.11.5)
73
73
  rubocop (>= 1.7.0, < 2.0)
74
74
  rubocop-ast (>= 0.4.0)
75
75
  rubocop-rake (0.6.0)
@@ -81,7 +81,7 @@ GEM
81
81
  sqlite3 (1.4.2)
82
82
  tzinfo (2.0.4)
83
83
  concurrent-ruby (~> 1.0)
84
- unicode-display_width (2.0.0)
84
+ unicode-display_width (2.1.0)
85
85
  zeitwerk (2.4.2)
86
86
 
87
87
  PLATFORMS
data/fleiss.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'fleiss'
3
- s.version = '0.4.3'
3
+ s.version = '0.4.4'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(Minimialist background jobs backed by ActiveJob and ActiveRecord.)
@@ -3,11 +3,11 @@ require 'fleiss'
3
3
  module ActiveJob
4
4
  module QueueAdapters
5
5
  class FleissAdapter
6
- def enqueue(job) #:nodoc:
6
+ def enqueue(job) # :nodoc:
7
7
  enqueue_at(job, nil)
8
8
  end
9
9
 
10
- def enqueue_at(job, scheduled_at) #:nodoc:
10
+ def enqueue_at(job, scheduled_at) # :nodoc:
11
11
  job_id = Fleiss.backend.enqueue(job, scheduled_at: scheduled_at)
12
12
  job.provider_job_id = job_id
13
13
  job_id
@@ -20,7 +20,7 @@ module Fleiss
20
20
  def wrap_perform(&block)
21
21
  connection_pool.with_connection(&block)
22
22
  rescue ::ActiveRecord::StatementInvalid
23
- ::ActiveRecord::Base.clear_active_connections!
23
+ ::ActiveRecord::Base.clear_all_connections!
24
24
  raise
25
25
  end
26
26
 
data/lib/fleiss/worker.rb CHANGED
@@ -11,8 +11,6 @@ class Fleiss::Worker
11
11
  end
12
12
 
13
13
  # Init a new worker instance
14
- # @param [ConnectionPool] disque client connection pool
15
- # @param [Hash] options
16
14
  # @option [Array<String>] :queues queues to watch. Default: ["default"]
17
15
  # @option [Integer] :concurrency the number of concurrent pool. Default: 10
18
16
  # @option [Numeric] :wait_time maximum time (in seconds) to wait for jobs when retrieving next batch. Default: 1s.
@@ -62,16 +60,18 @@ class Fleiss::Worker
62
60
 
63
61
  batch.each do |job|
64
62
  @pool.post do
65
- Fleiss.backend.wrap_perform { perform(job) }
63
+ thread_id = Thread.current.object_id.to_s(16).reverse
64
+ Fleiss.backend.wrap_perform { perform(job, thread_id) }
65
+ rescue StandardError => e
66
+ log_exception e, "processing job ##{job.id} (by thread #{thread_id})"
66
67
  end
67
68
  end
68
69
  rescue StandardError => e
69
- handle_exception e, 'running cycle'
70
+ log_exception e, 'running cycle'
70
71
  end
71
72
 
72
- def perform(job)
73
- thread_id = Thread.current.object_id.to_s(16).reverse
74
- owner = "#{uuid}/#{thread_id}"
73
+ def perform(job, thread_id)
74
+ owner = "#{uuid}/#{thread_id}"
75
75
  return unless job.start(owner)
76
76
 
77
77
  log(:info) { "Worker #{uuid} execute job ##{job.id} (by thread #{thread_id})" }
@@ -85,11 +85,9 @@ class Fleiss::Worker
85
85
  ensure
86
86
  finished ? job.finish(owner) : job.reschedule(owner)
87
87
  end
88
- rescue StandardError => e
89
- handle_exception e, "processing job ##{job.id} (by thread #{thread_id})"
90
88
  end
91
89
 
92
- def handle_exception(err, intro)
90
+ def log_exception(err, intro)
93
91
  log(:error) do
94
92
  [
95
93
  "Worker #{uuid} error on #{intro}:",
@@ -125,7 +125,7 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
125
125
  end
126
126
 
127
127
  it 'reconnects' do
128
- expect(::ActiveRecord::Base).to receive(:clear_active_connections!).once.and_return(nil)
128
+ expect(::ActiveRecord::Base).to receive(:clear_all_connections!).once.and_return(nil)
129
129
 
130
130
  expect do
131
131
  described_class.wrap_perform { raise ::ActiveRecord::StatementInvalid }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fleiss
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
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob