sneakers_requeue_on_error 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '0778beaa123f85678b33e3b728b6b4294de124d5a5294616dca483df45080e98'
4
+ data.tar.gz: a48211b204a37184e9c7181bbf33d66592bbcd1f4c2d31db7670868dc1b75a88
5
+ SHA512:
6
+ metadata.gz: 0acba9e24b9bafedd9af164d46b19c41c36d1a59fea0d66faeb552f66d396cb5a8e93a90a1ca5887f14ffe1c77a0a441dc0a8bd702e36cef2e326e1994dd6cc0
7
+ data.tar.gz: 4e693f12051a46b5540bae34c179c9da4423335a7f52811d3cb0602a20f6e5d081bb6647aec307664173b3ae11298c263ec1f7312d6c53122b96176606f5103a
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.gem
10
+ /spec/lib/tmp
11
+ *.gem
12
+ Gemfile.lock
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,38 @@
1
+ image: "ruby:2.7"
2
+
3
+ stages:
4
+ - release
5
+ - test
6
+
7
+ before_script:
8
+ - gem install bundler --no-document
9
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
10
+
11
+ rspec:
12
+ script:
13
+ - bundle exec rspec
14
+
15
+ rubocop:
16
+ script:
17
+ - bundle exec rubocop
18
+
19
+ release:
20
+ stage: release
21
+ rules:
22
+ - if: '$CI_COMMIT_TAG'
23
+ script:
24
+ - mkdir -p ~/.gem
25
+ - touch ~/.gem/credentials
26
+ - cat $RUBYGEMS_CREDENTIALS > ~/.gem/credentials
27
+ - cat ~/.gem/credentials
28
+ - chmod 0600 ~/.gem/credentials
29
+ - gem update --system
30
+ - ruby --version
31
+ - gem env version
32
+ - sed -i "s/0.0.0/$CI_COMMIT_TAG/g" lib/sneakers_requeue_on_error/version.rb
33
+ - gem build sneakers_requeue_on_error.gemspec
34
+ - gem push sneakers_requeue_on_error*.gem
35
+ artifacts:
36
+ paths:
37
+ - sneakers_requeue_on_error*.gem
38
+ expire_in: 30 days
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
3
+
4
+ Style/GlobalVars:
5
+ Enabled: false
6
+ Style/FrozenStringLiteralComment:
7
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rubocop'
6
+ gem 'rubocop-shopify', "~> 1.0.4", require: false
7
+
8
+ gem 'rspec'
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # sneakers_requeue_on_error
2
+
3
+ A Sneakers worker handler that will re-queue the message when encountering an error.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sneakers_requeue_on_error'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install sneakers_requeue_on_error
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Given a Sneakers worker:
28
+
29
+ ```ruby
30
+ class MyWorker
31
+ include Sneakers::Worker
32
+
33
+ from_queue :a_queue,
34
+ handler: SneakersRequeueOnError::Handler,
35
+ prefetch: 10,
36
+
37
+ def work(message)
38
+ # Do something worthwhile
39
+ ack!
40
+ end
41
+ end
42
+ ```
43
+
44
+ Set the handler to be `SneakersRequeueOnError::Handler`.
45
+
46
+ From now on, if the `work` method encounters an error, the message will be place back on the queue.
47
+
48
+ Note that Sneakers has built in error handling around the `work` method, so you shouldn't attempt to catch any errors via `rescue` unless you want to bypass the error handling altogether.
49
+
50
+ ## Development
51
+
52
+ To contribute to this gem, simple clone the repository, run `bundle install` and run tests:
53
+
54
+ ```shell script
55
+ bundle exec rspec
56
+ bundle exec rubocop
57
+ ```
58
+
59
+ ## Releasing
60
+
61
+ The release process is tied to the git tags. Simply creating a new tag and pushing will trigger a new release to rubygems.
@@ -0,0 +1 @@
1
+ require 'sneakers_requeue_on_error/handler'
@@ -0,0 +1,27 @@
1
+ module SneakersRequeueOnError
2
+ class Handler
3
+ def initialize(channel, _queue, opts)
4
+ @channel = channel
5
+ @opts = opts
6
+ end
7
+
8
+ def acknowledge(hdr, _props, _msg)
9
+ @channel.acknowledge(hdr.delivery_tag, false)
10
+ end
11
+
12
+ def reject(hdr, _props, _msg, requeue = false)
13
+ @channel.reject(hdr.delivery_tag, requeue)
14
+ end
15
+
16
+ def error(hdr, props, msg, _err)
17
+ reject(hdr, props, msg, true)
18
+ end
19
+
20
+ def timeout(hdr, props, msg)
21
+ reject(hdr, props, msg)
22
+ end
23
+
24
+ def noop(hdr, props, msg)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module SneakersRequeueOnError
2
+ VERSION = '0.0.4'
3
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'lib/sneakers_requeue_on_error/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sneakers_requeue_on_error'
5
+ spec.version = SneakersRequeueOnError::VERSION
6
+ spec.authors = ['Chris Harrison']
7
+ spec.email = ['chris.harrison@nexusmods.com']
8
+
9
+ spec.summary = 'A Sneakers worker handler that will re-queue the message when encountering an error.'
10
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
11
+
12
+ # Specify which files should be added to the gem when it is released.
13
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
14
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
15
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ end
17
+ spec.require_paths = ['lib']
18
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sneakers_requeue_on_error
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Chris Harrison
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - chris.harrison@nexusmods.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".gitlab-ci.yml"
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - Gemfile
25
+ - README.md
26
+ - lib/sneakers_requeue_on_error.rb
27
+ - lib/sneakers_requeue_on_error/handler.rb
28
+ - lib/sneakers_requeue_on_error/version.rb
29
+ - sneakers_requeue_on_error.gemspec
30
+ homepage:
31
+ licenses: []
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 2.3.0
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.2.19
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: A Sneakers worker handler that will re-queue the message when encountering
52
+ an error.
53
+ test_files: []