background_worker 0.4.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +7 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +12 -0
- data/README.md +1 -0
- data/background_worker.gemspec +1 -3
- data/gemfiles/rails70.gemfile +8 -0
- data/lib/background_worker/base.rb +7 -2
- data/lib/background_worker/config.rb +1 -1
- data/lib/background_worker/version.rb +1 -1
- data/spec/base_spec.rb +8 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/coverage_loader.rb +1 -2
- metadata +5 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37f371795b57bf7461a9f02c9f74195daf9d3cb61328fd0eca5f69a2c61447b6
|
4
|
+
data.tar.gz: 393896f93efac8a56c0806a8664ea381fff12ff31a2e0e31c210d6a3480694b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dae022eecbd54ce73185739df605b3fa5ffd1efc12e411d86bd76f6bfac03f4e20616ac20ffdda04d7c3ef3c3d3d403dac69754a45b5ca9d6fb57daab2444acc
|
7
|
+
data.tar.gz: 0f9f04c606150a637744facdc4c9d9bb02ff1918d52b24fd92f5ebb47ec3606aab2e59567355422b485924352cc471f29e18d4be6438378e3ead11e0aeff3c96
|
data/.github/workflows/ruby.yml
CHANGED
@@ -5,8 +5,8 @@ jobs:
|
|
5
5
|
strategy:
|
6
6
|
fail-fast: false
|
7
7
|
matrix:
|
8
|
-
gemfile: [rails60, rails61]
|
9
|
-
ruby: ["2.
|
8
|
+
gemfile: [rails60, rails61, rails70]
|
9
|
+
ruby: ["2.7", "3.0", "3.1"]
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
env:
|
12
12
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
@@ -17,3 +17,8 @@ jobs:
|
|
17
17
|
ruby-version: ${{ matrix.ruby }}
|
18
18
|
bundler-cache: true
|
19
19
|
- run: bundle exec rake
|
20
|
+
- name: Coveralls
|
21
|
+
uses: coverallsapp/github-action@master
|
22
|
+
with:
|
23
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
24
|
+
path-to-lcov: coverage/lcov.info
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.0
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
5
5
|
|
6
|
+
## 0.7.0
|
7
|
+
|
8
|
+
- [PLAT-670] Add queue_as method
|
9
|
+
|
10
|
+
## 0.6.0
|
11
|
+
|
12
|
+
- [PLAT-664] Align interface to ActiveJob
|
13
|
+
|
14
|
+
## 0.5.0
|
15
|
+
|
16
|
+
- [PLAT-183] Ruby 3.1, Rails 7.0 and push coverage with github action
|
17
|
+
|
6
18
|
## 0.4.0
|
7
19
|
|
8
20
|
- [TT-8623] Update to build with github actions / ruby 3.0 / rails 6.1
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/background_worker.svg)](http://badge.fury.io/rb/background_worker)
|
4
4
|
[![Build Status](https://github.com/sealink/background_worker/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/sealink/background_worker/actions)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/sealink/background_worker/badge.png)](https://coveralls.io/r/sealink/background_worker)
|
5
6
|
|
6
7
|
Provides a worker abstraction with an additional status channel.
|
7
8
|
|
data/background_worker.gemspec
CHANGED
@@ -19,15 +19,13 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
20
20
|
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
21
21
|
spec.require_paths = ['lib']
|
22
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.7'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'activesupport'
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'rake'
|
27
27
|
spec.add_development_dependency 'rspec'
|
28
28
|
spec.add_development_dependency 'coverage-kit'
|
29
|
-
spec.add_development_dependency 'coveralls'
|
30
|
-
spec.add_development_dependency 'simplecov-rcov'
|
31
29
|
spec.add_development_dependency 'rubocop'
|
32
30
|
|
33
31
|
spec.add_development_dependency 'activerecord'
|
@@ -53,12 +53,13 @@ module BackgroundWorker
|
|
53
53
|
end
|
54
54
|
|
55
55
|
class << self
|
56
|
+
attr_reader :queue
|
56
57
|
def get_state_of(worker_id)
|
57
58
|
BackgroundWorker::PersistentState.get_state_of(worker_id)
|
58
59
|
end
|
59
60
|
|
60
61
|
# Public method to do in background...
|
61
|
-
def
|
62
|
+
def perform_later(method_name, options = {})
|
62
63
|
opts = options.symbolize_keys
|
63
64
|
|
64
65
|
method_name = method_name.to_sym
|
@@ -76,7 +77,7 @@ module BackgroundWorker
|
|
76
77
|
# This method is called by the job runner
|
77
78
|
#
|
78
79
|
# It will just call your preferred method in the worker.
|
79
|
-
def
|
80
|
+
def perform_now(method_name, options = {})
|
80
81
|
BackgroundWorker.verify_active_connections! if BackgroundWorker.config.backgrounded
|
81
82
|
|
82
83
|
worker = new(options)
|
@@ -85,6 +86,10 @@ module BackgroundWorker
|
|
85
86
|
ensure
|
86
87
|
BackgroundWorker.release_connections! if BackgroundWorker.config.backgrounded
|
87
88
|
end
|
89
|
+
|
90
|
+
def queue_as(queue = nil)
|
91
|
+
@queue = queue&.to_sym || :default
|
92
|
+
end
|
88
93
|
end
|
89
94
|
end
|
90
95
|
end
|
data/spec/base_spec.rb
CHANGED
@@ -32,8 +32,15 @@ describe BackgroundWorker::Base do
|
|
32
32
|
|
33
33
|
it 'should perform action and handle transactions/connections appropriately' do
|
34
34
|
Model.transaction do
|
35
|
-
worker_class.
|
35
|
+
worker_class.perform_later(:store_in_cache, value: 42)
|
36
36
|
end
|
37
37
|
expect(cache).to have_received(:store).with(42)
|
38
38
|
end
|
39
|
+
|
40
|
+
context '#queue_as' do
|
41
|
+
it 'should value queue correctly' do
|
42
|
+
worker_class.queue_as('low')
|
43
|
+
expect(worker_class.queue).to be :low
|
44
|
+
end
|
45
|
+
end
|
39
46
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: background_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -82,34 +82,6 @@ dependencies:
|
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: coveralls
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - ">="
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '0'
|
92
|
-
type: :development
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: simplecov-rcov
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - ">="
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '0'
|
106
|
-
type: :development
|
107
|
-
prerelease: false
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
requirements:
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '0'
|
113
85
|
- !ruby/object:Gem::Dependency
|
114
86
|
name: rubocop
|
115
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,6 +148,7 @@ files:
|
|
176
148
|
- background_worker.gemspec
|
177
149
|
- gemfiles/rails60.gemfile
|
178
150
|
- gemfiles/rails61.gemfile
|
151
|
+
- gemfiles/rails70.gemfile
|
179
152
|
- lib/background_worker.rb
|
180
153
|
- lib/background_worker/base.rb
|
181
154
|
- lib/background_worker/config.rb
|
@@ -200,14 +173,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
173
|
requirements:
|
201
174
|
- - ">="
|
202
175
|
- !ruby/object:Gem::Version
|
203
|
-
version: '2.
|
176
|
+
version: '2.7'
|
204
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
178
|
requirements:
|
206
179
|
- - ">="
|
207
180
|
- !ruby/object:Gem::Version
|
208
181
|
version: '0'
|
209
182
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.3.3
|
211
184
|
signing_key:
|
212
185
|
specification_version: 4
|
213
186
|
summary: Background worker abstraction with status updates
|