background_worker 0.3.0 → 0.4.0
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 +4 -4
- data/.bundle/config +2 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/release.yml +59 -0
- data/.github/workflows/ruby.yml +19 -0
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +34 -9
- data/background_worker.gemspec +1 -0
- data/gemfiles/rails60.gemfile +8 -0
- data/gemfiles/rails61.gemfile +8 -0
- data/lib/background_worker/version.rb +1 -1
- metadata +10 -6
- data/.travis.yml +0 -11
- data/gemfiles/rails5_2.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2f1d5ad9dc6f2f79dfcd55838f8b7d9ded9c7518fc77f90ecea89fe537539c
|
4
|
+
data.tar.gz: 1e05a4e548ebdfea30e6bcf9ecc20dd7aaa3edc75966a2433f1f8ca016eb879c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c98bc9599be6db3a4a5f5dd6b8dc699a9209dcf6889553ae786ee7c780198d4af3c37198fdf486477f5a150288c1ab818632eeefb655bf7453c5372806ba4871
|
7
|
+
data.tar.gz: 19d317689204f81a81f782c6a8697087c13d5616341abd6258a0284249804fd216c389cf07e738993b522ec1346c517224a040531a574428233e0170502eb506
|
data/.bundle/config
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- "v*"
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: Build
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- name: Checkout
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
bundler-cache: true
|
18
|
+
- run: bundle exec rake
|
19
|
+
|
20
|
+
release:
|
21
|
+
needs: build
|
22
|
+
name: Release
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
steps:
|
25
|
+
- name: Checkout
|
26
|
+
uses: actions/checkout@v2
|
27
|
+
|
28
|
+
- name: Generate Changelog
|
29
|
+
run: |
|
30
|
+
# Get version from github ref (remove 'refs/tags/' and prefix 'v')
|
31
|
+
version="${GITHUB_REF#refs/tags/v}"
|
32
|
+
npx changelog-parser CHANGELOG.md | jq -cr ".versions | .[] | select(.version == \"$version\") | .body" > ${{ github.workflow }}-CHANGELOG.txt
|
33
|
+
|
34
|
+
- name: Release
|
35
|
+
uses: softprops/action-gh-release@v1
|
36
|
+
with:
|
37
|
+
body_path: ${{ github.workflow }}-CHANGELOG.txt
|
38
|
+
env:
|
39
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
40
|
+
|
41
|
+
publish:
|
42
|
+
needs: [build, release]
|
43
|
+
name: Publish
|
44
|
+
runs-on: ubuntu-latest
|
45
|
+
|
46
|
+
steps:
|
47
|
+
- uses: actions/checkout@v2
|
48
|
+
- uses: ruby/setup-ruby@v1
|
49
|
+
|
50
|
+
- name: Publish to RubyGems
|
51
|
+
run: |
|
52
|
+
mkdir -p $HOME/.gem
|
53
|
+
touch $HOME/.gem/credentials
|
54
|
+
chmod 0600 $HOME/.gem/credentials
|
55
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
56
|
+
gem build *.gemspec
|
57
|
+
gem push *.gem
|
58
|
+
env:
|
59
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Build and Test
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
gemfile: [rails60, rails61]
|
9
|
+
ruby: ["2.6", "2.7", "3.0"]
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
env:
|
12
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true
|
19
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ 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.4.0
|
7
|
+
|
8
|
+
- [TT-8623] Update to build with github actions / ruby 3.0 / rails 6.1
|
9
|
+
|
6
10
|
## 0.3.0
|
7
11
|
|
8
12
|
- [TT-6292] Support Rails 5.2 built-in redis cache, remove legacy supports
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
Background Worker
|
2
|
-
|
1
|
+
# Background Worker
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/background_worker)
|
4
|
+
[](https://github.com/sealink/background_worker/actions)
|
3
5
|
|
4
6
|
Provides a worker abstraction with an additional status channel.
|
5
7
|
|
6
8
|
Start by making a worker class which extends from BackgroundWorker::Base
|
7
9
|
|
10
|
+
```ruby
|
8
11
|
class MyWorker < BackgroundWorker::Base
|
9
12
|
def my_task(options={})
|
10
13
|
report_progress('Starting')
|
@@ -17,22 +20,27 @@ Start by making a worker class which extends from BackgroundWorker::Base
|
|
17
20
|
{original_message: message}
|
18
21
|
end
|
19
22
|
end
|
23
|
+
```
|
20
24
|
|
21
25
|
Then, when you want to perform a task in the background, use
|
22
26
|
klass#perform_in_background which exists in Base:
|
23
27
|
|
28
|
+
```ruby
|
24
29
|
worker_id = MyWorker.perform_in_background(:my_task, message: "hello!")
|
30
|
+
```
|
25
31
|
|
26
32
|
# Backgrounded
|
27
33
|
|
28
34
|
By default this will call your instance method in the foreground -- you have to
|
29
35
|
provide an #enqueue_with configuration like so:
|
30
36
|
|
37
|
+
```ruby
|
31
38
|
BackgroundWorker.configure(
|
32
39
|
enqueue_with: -> klass, method_name, options {
|
33
40
|
Resque.enqueue(klass, method_name, options)
|
34
41
|
}
|
35
42
|
)
|
43
|
+
```
|
36
44
|
|
37
45
|
This is independent of the status reporting which (currently) always uses Redis.
|
38
46
|
|
@@ -41,23 +49,40 @@ This is independent of the status reporting which (currently) always uses Redis.
|
|
41
49
|
The worker_id you are returned can be used to get the status and
|
42
50
|
whether the worker has finished successfully, failed, or is still in progress:
|
43
51
|
|
52
|
+
```ruby
|
44
53
|
state = BackgroundWorker.get_state_of(worker_id)
|
54
|
+
```
|
45
55
|
|
46
56
|
The state is represented by a hash with the following keys:
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
| key | description |
|
59
|
+
| ------------------------------------------------------------ | -------------------------------------------------------------------- |
|
60
|
+
| message | Reported message |
|
61
|
+
| detailed_message | Detailed version of above when provided |
|
62
|
+
| status | :successful, :failed, or null if still processing |
|
63
|
+
| completed | True if report_failed, report_successful called (or worker |
|
64
|
+
| finished without exception -- which calls report_successful) |
|
65
|
+
| data | Arbitrary data returned by worker method on success or report_failed |
|
54
66
|
|
55
67
|
If an exception is raised, the worker will call #report_failed with the
|
56
68
|
details. You can provide a callback with #after_exception in the config.
|
57
69
|
|
58
|
-
#
|
70
|
+
# Installation
|
59
71
|
|
60
72
|
Add to your Gemfile:
|
61
73
|
|
74
|
+
```ruby
|
62
75
|
gem 'background_worker'
|
76
|
+
```
|
77
|
+
|
78
|
+
# Release
|
79
|
+
|
80
|
+
To publish a new version of this gem the following steps must be taken.
|
63
81
|
|
82
|
+
- Update the version in the following files
|
83
|
+
```
|
84
|
+
CHANGELOG.md
|
85
|
+
lib/background_worker/version.rb
|
86
|
+
```
|
87
|
+
- Create a tag using the format v0.1.0
|
88
|
+
- Follow build progress in GitHub actions
|
data/background_worker.gemspec
CHANGED
@@ -19,6 +19,7 @@ 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.6'
|
22
23
|
|
23
24
|
spec.add_development_dependency 'activesupport'
|
24
25
|
spec.add_development_dependency 'bundler'
|
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.4.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: 2021-01-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -161,17 +161,21 @@ executables: []
|
|
161
161
|
extensions: []
|
162
162
|
extra_rdoc_files: []
|
163
163
|
files:
|
164
|
+
- ".bundle/config"
|
165
|
+
- ".github/dependabot.yml"
|
166
|
+
- ".github/workflows/release.yml"
|
167
|
+
- ".github/workflows/ruby.yml"
|
164
168
|
- ".gitignore"
|
165
169
|
- ".rubocop.yml"
|
166
170
|
- ".ruby-version"
|
167
|
-
- ".travis.yml"
|
168
171
|
- CHANGELOG.md
|
169
172
|
- Gemfile
|
170
173
|
- LICENSE.txt
|
171
174
|
- README.md
|
172
175
|
- Rakefile
|
173
176
|
- background_worker.gemspec
|
174
|
-
- gemfiles/
|
177
|
+
- gemfiles/rails60.gemfile
|
178
|
+
- gemfiles/rails61.gemfile
|
175
179
|
- lib/background_worker.rb
|
176
180
|
- lib/background_worker/base.rb
|
177
181
|
- lib/background_worker/config.rb
|
@@ -196,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
200
|
requirements:
|
197
201
|
- - ">="
|
198
202
|
- !ruby/object:Gem::Version
|
199
|
-
version: '
|
203
|
+
version: '2.6'
|
200
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
205
|
requirements:
|
202
206
|
- - ">="
|
203
207
|
- !ruby/object:Gem::Version
|
204
208
|
version: '0'
|
205
209
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
210
|
+
rubygems_version: 3.2.3
|
207
211
|
signing_key:
|
208
212
|
specification_version: 4
|
209
213
|
summary: Background worker abstraction with status updates
|
data/.travis.yml
DELETED