queue_classic 3.2.0.RC1 → 4.0.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +151 -0
  3. data/.gitignore +2 -0
  4. data/{changelog → CHANGELOG.md} +80 -34
  5. data/CODE_OF_CONDUCT.md +46 -0
  6. data/Gemfile +8 -5
  7. data/README.md +77 -85
  8. data/Rakefile +2 -0
  9. data/lib/generators/queue_classic/install_generator.rb +6 -0
  10. data/lib/generators/queue_classic/templates/add_queue_classic.rb +3 -1
  11. data/lib/generators/queue_classic/templates/update_queue_classic_3_0_0.rb +3 -1
  12. data/lib/generators/queue_classic/templates/update_queue_classic_3_0_2.rb +3 -1
  13. data/lib/generators/queue_classic/templates/update_queue_classic_3_1_0.rb +3 -1
  14. data/lib/generators/queue_classic/templates/update_queue_classic_4_0_0.rb +11 -0
  15. data/lib/queue_classic.rb +4 -11
  16. data/lib/queue_classic/config.rb +2 -1
  17. data/lib/queue_classic/conn_adapter.rb +28 -14
  18. data/lib/queue_classic/queue.rb +65 -11
  19. data/lib/queue_classic/railtie.rb +2 -0
  20. data/lib/queue_classic/setup.rb +24 -7
  21. data/lib/queue_classic/tasks.rb +4 -5
  22. data/lib/queue_classic/version.rb +3 -1
  23. data/lib/queue_classic/worker.rb +10 -5
  24. data/queue_classic.gemspec +1 -1
  25. data/sql/create_table.sql +7 -16
  26. data/sql/ddl.sql +6 -82
  27. data/sql/downgrade_from_4_0_0.sql +88 -0
  28. data/sql/update_to_3_0_0.sql +5 -5
  29. data/sql/update_to_3_1_0.sql +6 -6
  30. data/sql/update_to_4_0_0.sql +6 -0
  31. data/test/benchmark_test.rb +2 -0
  32. data/test/config_test.rb +2 -0
  33. data/test/helper.rb +34 -0
  34. data/test/lib/queue_classic_rails_connection_test.rb +9 -6
  35. data/test/lib/queue_classic_test.rb +2 -0
  36. data/test/queue_test.rb +62 -2
  37. data/test/rails-tests/.gitignore +2 -0
  38. data/test/rails-tests/rails523.sh +23 -0
  39. data/test/worker_test.rb +138 -17
  40. metadata +15 -7
  41. data/.travis.yml +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 173f9534b0c2b7318cccdf7de96b762ee63306d3
4
- data.tar.gz: c808e6bc17371a57e997c13800ba803666be969e
2
+ SHA256:
3
+ metadata.gz: '048980a61b1882135be9a0379bcd9e76c1353f361e1320c99478e0f4486dcab8'
4
+ data.tar.gz: b54392096329149b1d11195be20cac1ca8213174602e265d0e392a9816dc2ddb
5
5
  SHA512:
6
- metadata.gz: 7065d297515c3cd9bc40ac5f93a36f164d124f812dc2c53a649b163aceecf9995ebc07bee273660a4540defd08b95afc5b0b69f7b6af1491fd25f8c61cdbb927
7
- data.tar.gz: 9f4abe2f2f6c58a5bc4f049b0851d63e730c2922dcf8141a14222e01e2900c7993db939033925ebb684c88b6452e689269c3bbccb2e7386a60a4eacf24308aed
6
+ metadata.gz: 1c25ab7cc785b3715b3328e2214f2efd186a962dfcae86d31bfe75cecd6d4bcd0e2d68f7c9f38bc4727784f07b0fa48511fc04769ff13fc4d4056ceccd107272
7
+ data.tar.gz: adb4e07cbb115645ec6e54db85437b3e10388329ffd1d3688516ef00f4e1a8112dafecad1921e1ee12232650cd6a22c468bbc5e719affaf452f56b12f068141c
@@ -0,0 +1,151 @@
1
+ version: 2
2
+ jobs:
3
+ test_fresh_install_rails_5_2_3:
4
+ parallelism: 2
5
+ docker:
6
+ - image: circleci/ruby:2.6.3
7
+ environment:
8
+ RAILS_ENV: test
9
+ RACK_ENV: test
10
+ POSTGRES_USER: root
11
+ PGHOST: 127.0.0.1
12
+ DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
13
+ QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
14
+ QC_BENCHMARK: true
15
+ QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
16
+ - image: circleci/postgres:9.6.6-alpine
17
+ steps:
18
+ - checkout
19
+ - run:
20
+ name: Install rails, add QC and run migrations
21
+ command: |
22
+ cd test/rails-tests/
23
+ sh rails523.sh
24
+ test_ruby_2_4_6:
25
+ docker:
26
+ - image: circleci/ruby:2.4.6
27
+ environment:
28
+ RAILS_ENV: test
29
+ RACK_ENV: test
30
+ POSTGRES_USER: root
31
+ PGHOST: 127.0.0.1
32
+ DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
33
+ QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
34
+ QC_BENCHMARK: true
35
+ QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
36
+ - image: circleci/postgres:9.6.6-alpine
37
+ steps:
38
+ - checkout
39
+ - run:
40
+ name: Install env dependencies
41
+ command: |
42
+ sudo apt-get update
43
+ sudo apt-get install postgresql-client
44
+ - restore_cache:
45
+ key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
46
+ }}
47
+ - run:
48
+ name: Install Ruby gems
49
+ command: |
50
+ bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
51
+ - save_cache:
52
+ key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
53
+ }}
54
+ paths:
55
+ - ~/project/vendor/bundle
56
+ - run:
57
+ name: Minitest
58
+ command: |
59
+ bundle exec rake
60
+ - store_artifacts:
61
+ path: test/reports/
62
+ - store_test_results:
63
+ path: test/reports/
64
+ test_ruby_2_5_4:
65
+ docker:
66
+ - image: circleci/ruby:2.5.4
67
+ environment:
68
+ RAILS_ENV: test
69
+ RACK_ENV: test
70
+ POSTGRES_USER: root
71
+ PGHOST: 127.0.0.1
72
+ DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
73
+ QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
74
+ QC_BENCHMARK: true
75
+ QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
76
+ - image: circleci/postgres:9.6.6-alpine
77
+ steps:
78
+ - checkout
79
+ - run:
80
+ name: Install env dependencies
81
+ command: |
82
+ sudo apt-get update
83
+ sudo apt-get install postgresql-client
84
+ - restore_cache:
85
+ key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
86
+ }}
87
+ - run:
88
+ name: Install Ruby gems
89
+ command: |
90
+ bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
91
+ - save_cache:
92
+ key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
93
+ }}
94
+ paths:
95
+ - ~/project/vendor/bundle
96
+ - run:
97
+ name: Minitest
98
+ command: |
99
+ bundle exec rake
100
+ - store_artifacts:
101
+ path: test/reports/
102
+ - store_test_results:
103
+ path: test/reports/
104
+ test_ruby_2_6_3:
105
+ docker:
106
+ - image: circleci/ruby:2.6.3
107
+ environment:
108
+ RAILS_ENV: test
109
+ RACK_ENV: test
110
+ POSTGRES_USER: root
111
+ PGHOST: 127.0.0.1
112
+ DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
113
+ QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
114
+ QC_BENCHMARK: true
115
+ QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
116
+ - image: circleci/postgres:9.6.6-alpine
117
+ steps:
118
+ - checkout
119
+ - run:
120
+ name: Install env dependencies
121
+ command: |
122
+ sudo apt-get update
123
+ sudo apt-get install postgresql-client
124
+ - restore_cache:
125
+ key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
126
+ }}
127
+ - run:
128
+ name: Install Ruby gems
129
+ command: |
130
+ bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
131
+ - save_cache:
132
+ key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
133
+ }}
134
+ paths:
135
+ - ~/project/vendor/bundle
136
+ - run:
137
+ name: Minitest
138
+ command: |
139
+ bundle exec rake
140
+ - store_artifacts:
141
+ path: test/reports/
142
+ - store_test_results:
143
+ path: test/reports/
144
+ workflows:
145
+ version: 2
146
+ test:
147
+ jobs:
148
+ - test_ruby_2_4_6
149
+ - test_ruby_2_5_4
150
+ - test_ruby_2_6_3
151
+ - test_fresh_install_rails_5_2_3
data/.gitignore CHANGED
@@ -7,3 +7,5 @@ etc/
7
7
  .env
8
8
  Gemfile.lock
9
9
  tips-and-tricks.md
10
+ test/reports/
11
+ vendor/
@@ -1,31 +1,53 @@
1
- Unreleased
2
- - Fixed a bug in the offset calculation of `.enqueue_at`.
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [4.0.0-alpha1] - 2019-07-18
6
+
7
+ Updates:
8
+ - [Change to only support >= Postgres 9.6. We will be bringing in newer changes and testing on only 9.6+ going forward.](https://github.com/QueueClassic/queue_classic/pull/307)
9
+ - [Change to only support currently supported Ruby versions: 2.4, 2.5 and 2.6.](https://github.com/QueueClassic/queue_classic/pull/305)
10
+ - [Use skip-locked](https://github.com/QueueClassic/queue_classic/pull/303)
11
+ - [Add abilty to count ready and scheduled jobs](https://github.com/QueueClassic/queue_classic/pull/255)
12
+
13
+ Bug fixes:
14
+ - [Switched project to use CircleCI, as it's way more consistent speed wise](https://github.com/QueueClassic/queue_classic/pull/304)
15
+ - [Automatically retry after a connection reset #294](https://github.com/QueueClassic/queue_classic/pull/294)
16
+ - [Add tests for installing fresh on rails 5.2.3 + running migrations](https://github.com/QueueClassic/queue_classic/pull/308)
17
+ - [Don't recuse Time.now errors](https://github.com/QueueClassic/queue_classic/pull/310)
3
18
  - Use the jsonb type for the args column from now on. If not available, fall back to json or text.
4
19
  - `enqueue`, `enqueue_at`, `enqueue_in` return job hash with id.
5
- - Fixed unlock query for versions below Postgres 9.2
20
+ - Fixed a bug in the offset calculation of `.enqueue_at`.
21
+
22
+ ## [3.0.0rc] - 2014-01-07
6
23
 
7
- Version 3.0.0rc
8
24
  - Improved signal handling
9
25
 
10
- Version 3.0.0beta
26
+ ## [3.0.0beta] - 2014-01-06
27
+
11
28
  - Workers can process many queues.
12
29
 
13
- Version 2.2.3
30
+ ## [2.2.3] - 2013-10-24
31
+
14
32
  - Update pg dependency to 0.17.0
15
33
 
16
- Version 2.3.0beta [YANKED]
34
+ ## [2.3.0beta] - 2013-09-05 YANKED
35
+
17
36
  - Concurrent job processing.
18
37
 
19
- Version 2.2.2
38
+ ## [2.2.2] - 2013-08-04
39
+
20
40
  - Update pg dependency to 0.16.0
21
41
 
22
- Version 2.2.1
42
+ ## [2.2.1] - 2013-07-12
43
+
23
44
  - Force listen/notify on worker
24
45
  - Notifications happen inside PostgreSQL trigger
25
46
  - Add rake task for generating rails migrations
26
47
  - Fix bug related to listening worker
27
48
 
28
- Version 2.2.0
49
+ ## [2.2.0] - 2013-07-02
50
+
29
51
  - Use json from the stdlib in place of MultiJson.
30
52
  - Use postgresql's json type for the args column if json type is available
31
53
  - QC::Worker#handle_failure logs the job and the error
@@ -33,53 +55,65 @@ Version 2.2.0
33
55
  in testing to configure a mock queue)
34
56
  - QC.log now reports time elapsed in milliseconds.
35
57
 
36
- Version 2.1.4
58
+ ## [2.1.4]
59
+
37
60
  - Update pg dependency to 0.15.1
38
61
  - Document logging behaviour
39
62
 
40
- Version 2.1.3
63
+ ## [2.1.3]
64
+
41
65
  - Use MultiJson (Ezekiel Templin: #106)
42
66
 
43
- Version 2.1.2
67
+ ## [2.1.2]
68
+
44
69
  - Use 64bit ints as default data types in PostgreSQL
45
70
  - Add process method in worker
46
71
  - Allow percent-encoded socket paths in DATABASE_URL
47
72
 
48
- Version 2.1.1
73
+ ## [2.1.1]
74
+
49
75
  - Update pg gem version
50
76
 
51
- Version 2.1.0
77
+ ## [2.1.0]
78
+
52
79
  - Wrap connection execution in mutex making it thread safe
53
80
  - Cleanup logging
54
81
  - Refactor worker class making it more extensible
55
82
  - Added rdoc style docs for worker class
56
83
 
57
- Version 2.0.5
84
+ ## [2.0.5]
85
+
58
86
  - Allow term signal to halt the lock_job function
59
87
 
60
- Version 2.0.4
88
+ ## [2.0.4]
89
+
61
90
  - Provider a connection setter.
62
91
 
63
- Version 2.0.3
92
+ ## [2.0.3]
93
+
64
94
  - Fix typo :(
65
95
 
66
- Version 2.0.2
96
+ ## [2.0.2]
97
+
67
98
  - Remove scrolls dependency
68
99
  - Fix issue with notify not working on non-default queues
69
100
 
70
- Version 2.0.1
101
+ ## [2.0.1]
102
+
103
+ ## [2.0.0]
71
104
 
72
- Version 2.0.0
73
105
  - Simpler setup via QC::Setup.create (rake qc:create) & QC::Setup.drop (rake
74
106
  qc:drop)
75
107
  - Simpler abstractions in implementation
76
108
  - Better support for instrumentation via log_yield hook in QC module
77
109
  - Multiple queues use one table with a queue_name column
78
110
 
79
- Version 1.0.2
111
+ ## [1.0.2]
112
+
80
113
  - Update to latest okjson as the current has bugs
81
114
 
82
- Version 1.0.1
115
+ ## [1.0.1]
116
+
83
117
  - Using OkJson instead of any sort of rubygem
84
118
  - Remove html from docs
85
119
  - Use parameterised queries
@@ -87,35 +121,42 @@ Version 1.0.1
87
121
  - Injection attack bug fixed in lock_head()
88
122
  - Notificaiton get sent on seperate chans for disjoint queues
89
123
 
90
- Version 1.0.0rc1
124
+ ## [1.0.0rc1] - 2011-08-29
125
+
91
126
  - Removed json gem and relying on ruby 1.9.2's stdlib
92
127
  - Added better documentation
93
128
 
94
- Version 0.3.6pre
129
+ ## [0.3.6pre]
130
+
95
131
  - Added listen/notify support configured by $QC_LISTENING_WORKER otherwise uses Kernel.sleep()
96
132
 
97
- Version 0.3.5pre
133
+ ## [0.3.5pre] - 2011-08-27
134
+
98
135
  - Removed debug statement. Mistake!
99
136
 
100
- Version 0.3.4pre
137
+ ## [0.3.4pre]
138
+
101
139
  - Added logging configured by $VERBOSE or $QC_VERBOSE.
102
140
  - Added a method setup_child that gets called right after a worker forks.
103
141
  - Removed database helper methods: create_table, drop_table, silence_warnings.
104
142
  - Removed queue connection helper methods. Status should be discoverd by psql or the likes.
105
143
 
106
- Version 0.3.3pre
144
+ ## [0.3.3pre]
145
+
107
146
  - Removed PUB/SUB
108
147
  - Added GC after working a job
109
148
  - Added support for a database_url other than $DATABASE_URL. $QC_DATABASE_URL
110
149
  - Added exp backoff configured by $QC_MAX_LOCK_ATTEMPTS (default = 5)
111
150
  - Added option for forking worker configured by $QC_FORK_WORKER (default = false)
112
151
 
113
- Version 0.3.2
152
+ ## [0.3.2] - 2011-08-03
153
+
114
154
  - Fixed bug which caused workers to consume 2 connections. Now they only consume 1
115
155
  - Added a rake file for tests
116
156
  - Added support for postgres:///db_name DATABASE_URLs
117
157
 
118
- Version 0.3.1
158
+ ## [0.3.1] - 2011-04-27
159
+
119
160
  - Added query interface for introspection success
120
161
  - Moved the locking of jobs into the DB as a PG function. SELECT lock_head()
121
162
  - Added requirement for DB connection. MUST BE URI i.e. DATABASE_URL=postgres://user:pass@localhost/db_name
@@ -126,21 +167,26 @@ Version 0.3.1
126
167
  - Renamed the jobs channel to queue_classic_jobs
127
168
  - Added support for multiple queues
128
169
 
129
- Version 0.2.2
170
+ ## [0.2.2] - 2011-02-26
171
+
130
172
  - Fixed problems with enqueueing a list of parameters.
131
173
 
132
- Version 0.2.1
174
+ ## [0.2.1] - 2011-02-22
175
+
133
176
  - Added method for handling errors.
134
177
  - Added ability to enqueue a Job instance. Makes retrying jobs easier.
135
178
  - Added delete_all.
136
179
  - Fixed connection algorithm. 1 connection per process.
137
180
  - Fixed API for enqueue. Now accepting 1 arg or many args.
138
181
 
139
- Version 0.2.0
182
+ ## [0.2.0] - 2011-02-17
183
+
140
184
  - Beta Release
141
185
  - Added method for handling failed jobs
142
186
  - Added Benchmarks
143
187
  - Removed logging
144
188
  - Moved the Job class into it's own file
145
189
 
146
- 0.1.6
190
+ ## [0.1.6] - 2011-02-03
191
+
192
+ - Early release
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at isitaboat+qc@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,9 +1,12 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gem "rake"
3
+ source 'https://rubygems.org' do
4
+ gem 'rake'
4
5
 
5
- gemspec
6
+ gemspec
6
7
 
7
- group :test do
8
- gem 'minitest', '~> 5.5.1'
8
+ group :test do
9
+ gem 'minitest', '~> 5.8'
10
+ gem 'minitest-reporters'
11
+ end
9
12
  end