upperkut 1.0.2 → 1.0.3

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: edf84d6612f4c9577cfe53e578e16983e3936863379c7d4c1041e9c92637f867
4
- data.tar.gz: ce0ad624fe65306bb8fe818b8018acfe519326cbb744ef9af0519b26fd25faed
3
+ metadata.gz: 731a0ea07d1228421c4c5a306f3de6217e11f2a594e25e28ebf333f85056c9cc
4
+ data.tar.gz: 35680bb770644d47331488900de47a8ba1f2848d90cd8437511c1809ed15be32
5
5
  SHA512:
6
- metadata.gz: 3f6325ce299c9af7c50c9891acee2e771131d002c27b27fe6e245227d73ce177afd65451116daf7a5af5fc5e546b8b52b796ea82abf05bb8eae88966a16efa46
7
- data.tar.gz: 482e700d0cd87b0f6de61c528ef42d7c57bbc96afce8d5d6b1593420a4fa9308f6be668cc8c183fc98b9347a6a33800be9df5bebc3da98ac7a673f2204440cc2
6
+ metadata.gz: 0521a72596013f4e2333bf28e2e189df95dd36a781375a90e45f0f59ee59c39d1026d80822fceb798cf9fb929335a82019f50ffe701cbd48d8dfe89daafa0b06
7
+ data.tar.gz: 3e0f9d1e0449aa4d6e70d76e9ea954b29624fca7efe549812d5aad3f76d653ef4fc787e70e371bd2c1b06a51e366fc8e0406f351cf9275fa008a948ee724e08d
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upperkut
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Sousa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-04 00:00:00.000000000 Z
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 4.1.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 5.0.0
42
+ version: 6.0.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 4.1.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 5.0.0
52
+ version: 6.0.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -100,46 +100,7 @@ executables:
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
- - ".circleci/config.yml"
104
- - ".codeclimate.yml"
105
- - ".gitignore"
106
- - ".rspec"
107
- - CHANGELOG.md
108
- - CODE_OF_CONDUCT.md
109
- - Dockerfile
110
- - Gemfile
111
- - Gemfile.lock
112
- - LICENSE.txt
113
- - Makefile
114
- - README.md
115
- - Rakefile
116
103
  - bin/upperkut
117
- - docker-compose.yml
118
- - examples/basic.rb
119
- - examples/priority_worker.rb
120
- - examples/scheduled_worker.rb
121
- - examples/with_middlewares.rb
122
- - lib/upperkut.rb
123
- - lib/upperkut/cli.rb
124
- - lib/upperkut/core_ext.rb
125
- - lib/upperkut/item.rb
126
- - lib/upperkut/logging.rb
127
- - lib/upperkut/manager.rb
128
- - lib/upperkut/middleware.rb
129
- - lib/upperkut/middlewares/datadog.rb
130
- - lib/upperkut/middlewares/new_relic.rb
131
- - lib/upperkut/middlewares/rollbar.rb
132
- - lib/upperkut/processor.rb
133
- - lib/upperkut/redis_pool.rb
134
- - lib/upperkut/strategies/base.rb
135
- - lib/upperkut/strategies/buffered_queue.rb
136
- - lib/upperkut/strategies/priority_queue.rb
137
- - lib/upperkut/strategies/scheduled_queue.rb
138
- - lib/upperkut/util.rb
139
- - lib/upperkut/version.rb
140
- - lib/upperkut/worker.rb
141
- - lib/upperkut/worker_thread.rb
142
- - upperkut.gemspec
143
104
  homepage: http://shipit.resultadosdigitais.com.br/open-source/
144
105
  licenses:
145
106
  - MIT
@@ -152,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
113
  requirements:
153
114
  - - ">="
154
115
  - !ruby/object:Gem::Version
155
- version: 2.2.2
116
+ version: '3.0'
156
117
  required_rubygems_version: !ruby/object:Gem::Requirement
157
118
  requirements:
158
119
  - - ">="
159
120
  - !ruby/object:Gem::Version
160
121
  version: '0'
161
122
  requirements: []
162
- rubygems_version: 3.1.4
123
+ rubygems_version: 3.4.6
163
124
  signing_key:
164
125
  specification_version: 4
165
126
  summary: Batch background processing tool
data/.circleci/config.yml DELETED
@@ -1,65 +0,0 @@
1
- # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
- version: 2
6
- jobs:
7
- build:
8
- docker:
9
- - image: circleci/ruby:2.7.2
10
- environment:
11
- CC_TEST_REPORTER_ID: 03ab83a772148a577d29d4acf438d7ebdc95c632224122d0ba8dbb291eedebe6
12
- COVERAGE: true
13
- REDIS_URL: redis://localhost:6379
14
- - image: redis:5.0
15
- steps:
16
- - checkout
17
-
18
- # Download and cache dependencies
19
- - restore_cache:
20
- keys:
21
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
22
- # fallback to using the latest cache if no exact match is found
23
- - v1-dependencies-
24
-
25
- - run:
26
- name: install dependencies
27
- command: |
28
- bundle install --jobs=4 --retry=3 --path vendor/bundle
29
-
30
- - save_cache:
31
- paths:
32
- - ./vendor/bundle
33
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
34
-
35
- - run:
36
- name: Setup Code Climate test-reporter
37
- command: |
38
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
39
- chmod +x ./cc-test-reporter
40
- ./cc-test-reporter before-build
41
-
42
- # run tests!
43
- - run:
44
- name: run tests
45
- command: |
46
- mkdir /tmp/test-results
47
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
48
-
49
- bundle exec rspec --format progress \
50
- --format RspecJunitFormatter \
51
- --out /tmp/test-results/rspec.xml \
52
- --format progress \
53
- $TEST_FILES
54
- - run:
55
- name: Submit coverage
56
- command: |
57
- ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
58
-
59
- # collect reports
60
- - store_test_results:
61
- path: /tmp/test-results
62
-
63
- - store_artifacts:
64
- path: /tmp/test-results
65
- destination: test-results
data/.codeclimate.yml DELETED
@@ -1,15 +0,0 @@
1
- version: "2"
2
- plugins:
3
- brakeman:
4
- enabled: false
5
- eslint:
6
- enabled: false
7
- csslint:
8
- enabled: false
9
- rubocop:
10
- enabled: true
11
- channel: rubocop-0-63
12
- reek:
13
- enabled: true
14
- bundler-audit:
15
- enabled: true
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
- *.gem
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
4
- --order random
data/CHANGELOG.md DELETED
@@ -1,52 +0,0 @@
1
- # Upperkut changes
2
-
3
- 1.0.x
4
- -------
5
- - Add docker
6
- - Fix to_underscore bug for ruby 2.7.2 #83 @andrehjr;
7
-
8
-
9
- 0.8.x
10
- --------
11
- - Added exponential backoff when push_items #57
12
- - Introducing Item to avoid losing enqueued at and report wrong latency
13
- metrics #56 thanks to @jeangnc
14
-
15
- 0.7.x
16
- ---------
17
- - Fix logging timeout message #54 by @jeanmatheussouto
18
- - Add handle_error method #44
19
- - Added Datahog Middleware (#42)
20
- - Added Priority Queue (#39) thanks to @jeangnc and @jeanmatheussouto
21
- - Added Scheduled Queue Implementation thanks to @rodrigo-araujo #38
22
- - Added Datahog middleware #42 by @gabriel-augusto
23
- - Added redis to CI #40 by #henrich-m
24
- - Specs improvements #34 and #35, #37 by @gabriel-augusto
25
- - Enable Rubocop #32 by @henrich-m
26
- - Added codeclimate #31 by @henrich-m
27
- - Extract Buffered Queue behavior to its own strategy #29
28
-
29
- 0.6.x
30
- ---------
31
- - Set redis url when env var REDIS_URL is set thanks to @lucaskds #22
32
- - Enable users to pass their own connection pool also thanks to @lucaskds #21
33
- - Sets default concurrency to 1
34
- - Creates connection pools by default;
35
- - Simplifies API to enable extension via Strategy;
36
-
37
- 0.5.x
38
- ----------
39
- - Introducing client middlewares.
40
- - Fix issue that prevented worker to run.
41
- - Fix thread-unsafe code that was overwriting worker configurations when
42
- multiples workers were configured in the same process.
43
-
44
- 0.4.x
45
- -----------
46
-
47
- - Change redis versioning policy #17
48
- - Fixed error that prevented users from start upperkut from non Rails apps.
49
- - Added integration with Rollbar.
50
- - Added backtrace to logs when some error occurs.
51
- - Fixed NewRelic trace args
52
-
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at nandosousafr@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Dockerfile DELETED
@@ -1,7 +0,0 @@
1
- FROM ruby:2.7.2
2
-
3
- WORKDIR /code
4
- COPY . .
5
-
6
- RUN gem install bundler
7
- RUN bundle install
data/Gemfile DELETED
@@ -1,11 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in upperkut.gemspec
6
- gemspec
7
-
8
- gem 'fivemat'
9
- gem 'pry'
10
- gem 'rspec_junit_formatter'
11
- gem 'simplecov', '< 0.18', require: false
data/Gemfile.lock DELETED
@@ -1,58 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- upperkut (1.0.2)
5
- connection_pool (~> 2.2, >= 2.2.2)
6
- redis (>= 4.1.0, < 5.0.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- coderay (1.1.3)
12
- connection_pool (2.2.3)
13
- diff-lcs (1.4.4)
14
- docile (1.3.2)
15
- fivemat (1.3.7)
16
- json (2.3.1)
17
- method_source (1.0.0)
18
- pry (0.13.1)
19
- coderay (~> 1.1)
20
- method_source (~> 1.0)
21
- rake (13.0.1)
22
- redis (4.2.5)
23
- rspec (3.10.0)
24
- rspec-core (~> 3.10.0)
25
- rspec-expectations (~> 3.10.0)
26
- rspec-mocks (~> 3.10.0)
27
- rspec-core (3.10.0)
28
- rspec-support (~> 3.10.0)
29
- rspec-expectations (3.10.0)
30
- diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.10.0)
32
- rspec-mocks (3.10.0)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.10.0)
35
- rspec-support (3.10.0)
36
- rspec_junit_formatter (0.4.1)
37
- rspec-core (>= 2, < 4, != 2.12.0)
38
- simplecov (0.17.1)
39
- docile (~> 1.1)
40
- json (>= 1.8, < 3)
41
- simplecov-html (~> 0.10.0)
42
- simplecov-html (0.10.2)
43
-
44
- PLATFORMS
45
- ruby
46
-
47
- DEPENDENCIES
48
- bundler (>= 1.16)
49
- fivemat
50
- pry
51
- rake (~> 13.0)
52
- rspec (~> 3.0)
53
- rspec_junit_formatter
54
- simplecov (< 0.18)
55
- upperkut!
56
-
57
- BUNDLED WITH
58
- 2.1.4
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Nando Sousa
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/Makefile DELETED
@@ -1,4 +0,0 @@
1
- bash:
2
- docker-compose run gem bash
3
- specs:
4
- docker-compose run gem bundle exec rspec
data/README.md DELETED
@@ -1,162 +0,0 @@
1
- # Upperkut
2
-
3
- [![CircleCI](https://circleci.com/gh/ResultadosDigitais/upperkut/tree/master.svg?style=svg&circle-token=693e512de6985be3b3db12279ba6ed508fb5c6f6)](https://circleci.com/gh/ResultadosDigitais/upperkut/tree/master)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/ece40319b0db03af891d/maintainability)](https://codeclimate.com/repos/5b318a7c6d37b70272008676/maintainability)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/ece40319b0db03af891d/test_coverage)](https://codeclimate.com/repos/5b318a7c6d37b70272008676/test_coverage)
6
-
7
- [[Docs]](https://www.rubydoc.info/gems/upperkut/0.7.2/Upperkut)
8
-
9
- Background processing framework for Ruby applications.
10
-
11
- ## Installation
12
-
13
- Add this line to your application's Gemfile:
14
-
15
- ```ruby
16
- gem 'upperkut'
17
- ```
18
-
19
- And then execute:
20
-
21
- $ bundle
22
-
23
- Or install it yourself as:
24
-
25
- $ gem install upperkut
26
-
27
- ## Usage
28
-
29
- ### Example 1 - Buffered Queue:
30
-
31
- 1) Create a Worker class and the define how to process the batch;
32
- ```ruby
33
- class MyWorker
34
- include Upperkut::Worker
35
-
36
- def perform(batch_items)
37
- heavy_processing(batch_items)
38
- process_metrics(batch_items)
39
- end
40
- end
41
- ```
42
-
43
- 2) Start pushing items;
44
- ```ruby
45
- MyWorker.push_items(
46
- [
47
- {
48
- 'id' => SecureRandom.uuid,
49
- 'name' => 'Robert C Hall',
50
- 'action' => 'EMAIL_OPENNED'
51
- }
52
- ]
53
- )
54
- ```
55
-
56
- 3) Start Upperkut;
57
- ```bash
58
- $ bundle exec upperkut --worker MyWorker --concurrency 10
59
- ```
60
-
61
- ### Example 2 - Scheduled Queue:
62
-
63
- 1) Create a Worker class and the define how to process the batch;
64
- ```ruby
65
- require 'upperkut/strategies/scheduled_queue'
66
- class MyWorker
67
- include Upperkut::Worker
68
-
69
- setup_upperkut do |config|
70
- config.strategy = Upperkut::Strategies::ScheduledQueue.new(self)
71
- end
72
-
73
- def perform(batch_items)
74
- heavy_processing(batch_items)
75
- process_metrics(batch_items)
76
- end
77
- end
78
- ```
79
-
80
- 2) Start pushing items with `timestamp` parameter;
81
- ```ruby
82
- # timestamp is 'Thu, 10 May 2019 23:43:58 GMT'
83
- MyWorker.push_items(
84
- [
85
- {
86
- 'timestamp' => '1557531838',
87
- 'id' => SecureRandom.uuid,
88
- 'name' => 'Robert C Hall',
89
- 'action' => 'SEND_NOTIFICATION'
90
- }
91
- ]
92
- )
93
- ```
94
-
95
- 3) Start Upperkut;
96
- ```bash
97
- $ bundle exec upperkut --worker MyWorker --concurrency 10
98
- ```
99
-
100
- ### Example 3 - Priority Queue:
101
-
102
- Note: priority queues requires redis 5.0.0+ as it uses ZPOP* commands.
103
-
104
- 1) Create a Worker class and the define how to process the batch;
105
- ```ruby
106
- require 'upperkut/strategies/priority_queue'
107
-
108
- class MyWorker
109
- include Upperkut::Worker
110
-
111
- setup_upperkut do |config|
112
- config.strategy = Upperkut::Strategies::PriorityQueue.new(
113
- self,
114
- priority_key: -> { |item| item['tenant_id'] }
115
- )
116
- end
117
-
118
- def perform(items)
119
- items.each do |item|
120
- puts "event dispatched: #{item.inspect}"
121
- end
122
- end
123
- end
124
- ```
125
-
126
- 2) So you can enqueue items from different tenants;
127
- ```ruby
128
- MyWorker.push_items(
129
- [
130
- { 'tenant_id' => 1, 'id' => 1 },
131
- { 'tenant_id' => 1, 'id' => 2 },
132
- { 'tenant_id' => 1, 'id' => 3 },
133
- { 'tenant_id' => 2, 'id' => 4 },
134
- { 'tenant_id' => 3, 'id' => 5 },
135
- ]
136
- )
137
- ```
138
-
139
- The code above will enqueue items as follows `1, 4, 5, 2, 3`
140
-
141
- 3) Start Upperkut;
142
- ```bash
143
- $ bundle exec upperkut --worker MyWorker --concurrency 10
144
- ```
145
-
146
- ## Development
147
-
148
- After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rspec` to run the tests.
149
-
150
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
151
-
152
- ## Contributing
153
-
154
- Bug reports and pull requests are welcome on GitHub at https://github.com/ResultadosDigitais/upperkut. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
155
-
156
- ## License
157
-
158
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
159
-
160
- ## Code of Conduct
161
-
162
- Everyone interacting in the Upperkut project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ResultadosDigitais/upperkut/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/docker-compose.yml DELETED
@@ -1,18 +0,0 @@
1
- services:
2
- gem:
3
- build: .
4
- volumes:
5
- - .:/code
6
- environment:
7
- - REDIS_URL=redis://redis:6379
8
- depends_on:
9
- - redis
10
- redis:
11
- image: redis:5.0.4-alpine
12
- command: redis-server --save "" --appendonly yes --appendfsync everysec
13
- ports:
14
- - 6379:6379
15
- volumes:
16
- - redis-data:/data
17
- volumes:
18
- redis-data:
data/examples/basic.rb DELETED
@@ -1,12 +0,0 @@
1
- require_relative '../lib/upperkut/worker'
2
-
3
- class MyWorker
4
- include Upperkut::Worker
5
-
6
- def perform(items)
7
- puts 'starting performing'
8
- exec_time = rand(9000..50_000)
9
- sleep (exec_time.to_f / 1000.to_f)
10
- puts "performed #{items.size} items in #{exec_time.to_f / 1000.to_f} ms"
11
- end
12
- end
@@ -1,21 +0,0 @@
1
- require_relative '../lib/upperkut/worker'
2
- require_relative '../lib/upperkut/strategies/priority_queue'
3
-
4
- class PriorityWorker
5
- include Upperkut::Worker
6
-
7
- setup_upperkut do |config|
8
- config.strategy = Upperkut::Strategies::PriorityQueue.new(
9
- self,
10
- priority_key: -> { |item| item['tenant_id'] },
11
- batch_size: 1
12
- )
13
- end
14
-
15
- def perform(items)
16
- items.each do |item|
17
- puts "event dispatched: #{item.inspect}"
18
- sleep 1
19
- end
20
- end
21
- end