quiq 0.2.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 +7 -0
- data/.github/workflows/ruby.yml +20 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +174 -0
- data/LICENSE.txt +21 -0
- data/README.md +163 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/quiq +42 -0
- data/bin/quiqload +46 -0
- data/bin/setup +8 -0
- data/lib/quiq.rb +49 -0
- data/lib/quiq/client.rb +22 -0
- data/lib/quiq/config.rb +35 -0
- data/lib/quiq/job.rb +51 -0
- data/lib/quiq/queue.rb +65 -0
- data/lib/quiq/redis.rb +17 -0
- data/lib/quiq/scheduler.rb +51 -0
- data/lib/quiq/server.rb +28 -0
- data/lib/quiq/version.rb +5 -0
- data/lib/quiq/worker.rb +28 -0
- data/quiq.gemspec +30 -0
- data/testapp/Gemfile +15 -0
- data/testapp/Gemfile.lock +190 -0
- data/testapp/README.md +24 -0
- data/testapp/Rakefile +6 -0
- data/testapp/app/controllers/application_controller.rb +2 -0
- data/testapp/app/controllers/concerns/.keep +0 -0
- data/testapp/app/jobs/application_job.rb +7 -0
- data/testapp/app/jobs/http_job.rb +14 -0
- data/testapp/app/jobs/test_job.rb +9 -0
- data/testapp/app/models/concerns/.keep +0 -0
- data/testapp/bin/bundle +114 -0
- data/testapp/bin/rails +4 -0
- data/testapp/bin/rake +4 -0
- data/testapp/bin/setup +25 -0
- data/testapp/config.ru +5 -0
- data/testapp/config/application.rb +40 -0
- data/testapp/config/boot.rb +4 -0
- data/testapp/config/credentials.yml.enc +1 -0
- data/testapp/config/environment.rb +5 -0
- data/testapp/config/environments/development.rb +38 -0
- data/testapp/config/environments/production.rb +88 -0
- data/testapp/config/environments/test.rb +38 -0
- data/testapp/config/initializers/application_controller_renderer.rb +8 -0
- data/testapp/config/initializers/backtrace_silencers.rb +7 -0
- data/testapp/config/initializers/cors.rb +16 -0
- data/testapp/config/initializers/filter_parameter_logging.rb +4 -0
- data/testapp/config/initializers/inflections.rb +16 -0
- data/testapp/config/initializers/mime_types.rb +4 -0
- data/testapp/config/initializers/quiq.rb +29 -0
- data/testapp/config/initializers/wrap_parameters.rb +9 -0
- data/testapp/config/locales/en.yml +33 -0
- data/testapp/config/master.key +1 -0
- data/testapp/config/routes.rb +3 -0
- data/testapp/lib/tasks/.keep +0 -0
- data/testapp/public/robots.txt +1 -0
- data/testapp/tmp/.keep +0 -0
- data/testapp/tmp/development_secret.txt +1 -0
- data/testapp/tmp/pids/.keep +0 -0
- data/testapp/vendor/.keep +0 -0
- metadata +140 -0
data/quiq.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/quiq/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'quiq'
|
7
|
+
spec.version = Quiq::VERSION
|
8
|
+
spec.authors = ['Salim Semaoune']
|
9
|
+
|
10
|
+
spec.summary = 'Distributed task queue written in Ruby, backed by Redis and using event loops to handle concurrency.'
|
11
|
+
spec.description = <<-EOS
|
12
|
+
Quiq is a distributed task queue backed by Redis to process jobs in background.
|
13
|
+
It relies on asynchronous IOs to process multiple jobs simultaneously. The event loop is provided by the Async library and many other gems of the Socketry family.
|
14
|
+
EOS
|
15
|
+
spec.homepage = 'https://github.com/sailor/quiq'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = 'bin'
|
25
|
+
spec.executables = ['quiq']
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
|
28
|
+
spec.add_dependency 'async-redis', '~> 0.4.3'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
30
|
+
end
|
data/testapp/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
+
|
6
|
+
ruby '2.7.0'
|
7
|
+
|
8
|
+
gem 'bootsnap', '>= 1.4.2', require: false
|
9
|
+
gem 'quiq', path: '..'
|
10
|
+
gem 'async-http'
|
11
|
+
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'listen', '>= 3.0.5', '< 3.2'
|
15
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
quiq (0.1.0)
|
5
|
+
async-redis (~> 0.4.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.0.2.1)
|
11
|
+
actionpack (= 6.0.2.1)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (6.0.2.1)
|
15
|
+
actionpack (= 6.0.2.1)
|
16
|
+
activejob (= 6.0.2.1)
|
17
|
+
activerecord (= 6.0.2.1)
|
18
|
+
activestorage (= 6.0.2.1)
|
19
|
+
activesupport (= 6.0.2.1)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
actionmailer (6.0.2.1)
|
22
|
+
actionpack (= 6.0.2.1)
|
23
|
+
actionview (= 6.0.2.1)
|
24
|
+
activejob (= 6.0.2.1)
|
25
|
+
mail (~> 2.5, >= 2.5.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
actionpack (6.0.2.1)
|
28
|
+
actionview (= 6.0.2.1)
|
29
|
+
activesupport (= 6.0.2.1)
|
30
|
+
rack (~> 2.0, >= 2.0.8)
|
31
|
+
rack-test (>= 0.6.3)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
34
|
+
actiontext (6.0.2.1)
|
35
|
+
actionpack (= 6.0.2.1)
|
36
|
+
activerecord (= 6.0.2.1)
|
37
|
+
activestorage (= 6.0.2.1)
|
38
|
+
activesupport (= 6.0.2.1)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
actionview (6.0.2.1)
|
41
|
+
activesupport (= 6.0.2.1)
|
42
|
+
builder (~> 3.1)
|
43
|
+
erubi (~> 1.4)
|
44
|
+
rails-dom-testing (~> 2.0)
|
45
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
46
|
+
activejob (6.0.2.1)
|
47
|
+
activesupport (= 6.0.2.1)
|
48
|
+
globalid (>= 0.3.6)
|
49
|
+
activemodel (6.0.2.1)
|
50
|
+
activesupport (= 6.0.2.1)
|
51
|
+
activerecord (6.0.2.1)
|
52
|
+
activemodel (= 6.0.2.1)
|
53
|
+
activesupport (= 6.0.2.1)
|
54
|
+
activestorage (6.0.2.1)
|
55
|
+
actionpack (= 6.0.2.1)
|
56
|
+
activejob (= 6.0.2.1)
|
57
|
+
activerecord (= 6.0.2.1)
|
58
|
+
marcel (~> 0.3.1)
|
59
|
+
activesupport (6.0.2.1)
|
60
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
61
|
+
i18n (>= 0.7, < 2)
|
62
|
+
minitest (~> 5.1)
|
63
|
+
tzinfo (~> 1.1)
|
64
|
+
zeitwerk (~> 2.2)
|
65
|
+
async (1.24.2)
|
66
|
+
console (~> 1.0)
|
67
|
+
nio4r (~> 2.3)
|
68
|
+
timers (~> 4.1)
|
69
|
+
async-http (0.50.2)
|
70
|
+
async (~> 1.23)
|
71
|
+
async-io (~> 1.27.0)
|
72
|
+
async-pool (~> 0.2)
|
73
|
+
protocol-http (~> 0.13.0)
|
74
|
+
protocol-http1 (~> 0.10.0)
|
75
|
+
protocol-http2 (~> 0.10.0)
|
76
|
+
async-io (1.27.3)
|
77
|
+
async (~> 1.14)
|
78
|
+
async-pool (0.2.0)
|
79
|
+
async (~> 1.8)
|
80
|
+
async-redis (0.4.3)
|
81
|
+
async (~> 1.8)
|
82
|
+
async-io (~> 1.10)
|
83
|
+
async-pool (~> 0.2)
|
84
|
+
protocol-redis (~> 0.4.0)
|
85
|
+
bootsnap (1.4.5)
|
86
|
+
msgpack (~> 1.0)
|
87
|
+
builder (3.2.4)
|
88
|
+
concurrent-ruby (1.1.5)
|
89
|
+
console (1.8.1)
|
90
|
+
crass (1.0.6)
|
91
|
+
erubi (1.9.0)
|
92
|
+
ffi (1.12.1)
|
93
|
+
globalid (0.4.2)
|
94
|
+
activesupport (>= 4.2.0)
|
95
|
+
i18n (1.8.2)
|
96
|
+
concurrent-ruby (~> 1.0)
|
97
|
+
listen (3.1.5)
|
98
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
99
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
100
|
+
ruby_dep (~> 1.2)
|
101
|
+
loofah (2.4.0)
|
102
|
+
crass (~> 1.0.2)
|
103
|
+
nokogiri (>= 1.5.9)
|
104
|
+
mail (2.7.1)
|
105
|
+
mini_mime (>= 0.1.1)
|
106
|
+
marcel (0.3.3)
|
107
|
+
mimemagic (~> 0.3.2)
|
108
|
+
method_source (0.9.2)
|
109
|
+
mimemagic (0.3.3)
|
110
|
+
mini_mime (1.0.2)
|
111
|
+
mini_portile2 (2.4.0)
|
112
|
+
minitest (5.14.0)
|
113
|
+
msgpack (1.3.1)
|
114
|
+
nio4r (2.5.2)
|
115
|
+
nokogiri (1.10.7)
|
116
|
+
mini_portile2 (~> 2.4.0)
|
117
|
+
protocol-hpack (1.4.2)
|
118
|
+
protocol-http (0.13.1)
|
119
|
+
protocol-http1 (0.10.1)
|
120
|
+
protocol-http (~> 0.13)
|
121
|
+
protocol-http2 (0.10.4)
|
122
|
+
protocol-hpack (~> 1.4)
|
123
|
+
protocol-http (~> 0.2)
|
124
|
+
protocol-redis (0.4.2)
|
125
|
+
rack (2.1.1)
|
126
|
+
rack-test (1.1.0)
|
127
|
+
rack (>= 1.0, < 3)
|
128
|
+
rails (6.0.2.1)
|
129
|
+
actioncable (= 6.0.2.1)
|
130
|
+
actionmailbox (= 6.0.2.1)
|
131
|
+
actionmailer (= 6.0.2.1)
|
132
|
+
actionpack (= 6.0.2.1)
|
133
|
+
actiontext (= 6.0.2.1)
|
134
|
+
actionview (= 6.0.2.1)
|
135
|
+
activejob (= 6.0.2.1)
|
136
|
+
activemodel (= 6.0.2.1)
|
137
|
+
activerecord (= 6.0.2.1)
|
138
|
+
activestorage (= 6.0.2.1)
|
139
|
+
activesupport (= 6.0.2.1)
|
140
|
+
bundler (>= 1.3.0)
|
141
|
+
railties (= 6.0.2.1)
|
142
|
+
sprockets-rails (>= 2.0.0)
|
143
|
+
rails-dom-testing (2.0.3)
|
144
|
+
activesupport (>= 4.2.0)
|
145
|
+
nokogiri (>= 1.6)
|
146
|
+
rails-html-sanitizer (1.3.0)
|
147
|
+
loofah (~> 2.3)
|
148
|
+
railties (6.0.2.1)
|
149
|
+
actionpack (= 6.0.2.1)
|
150
|
+
activesupport (= 6.0.2.1)
|
151
|
+
method_source
|
152
|
+
rake (>= 0.8.7)
|
153
|
+
thor (>= 0.20.3, < 2.0)
|
154
|
+
rake (13.0.1)
|
155
|
+
rb-fsevent (0.10.3)
|
156
|
+
rb-inotify (0.10.1)
|
157
|
+
ffi (~> 1.0)
|
158
|
+
ruby_dep (1.5.0)
|
159
|
+
sprockets (4.0.0)
|
160
|
+
concurrent-ruby (~> 1.0)
|
161
|
+
rack (> 1, < 3)
|
162
|
+
sprockets-rails (3.2.1)
|
163
|
+
actionpack (>= 4.0)
|
164
|
+
activesupport (>= 4.0)
|
165
|
+
sprockets (>= 3.0.0)
|
166
|
+
thor (1.0.1)
|
167
|
+
thread_safe (0.3.6)
|
168
|
+
timers (4.3.0)
|
169
|
+
tzinfo (1.2.6)
|
170
|
+
thread_safe (~> 0.1)
|
171
|
+
websocket-driver (0.7.1)
|
172
|
+
websocket-extensions (>= 0.1.0)
|
173
|
+
websocket-extensions (0.1.4)
|
174
|
+
zeitwerk (2.2.2)
|
175
|
+
|
176
|
+
PLATFORMS
|
177
|
+
ruby
|
178
|
+
|
179
|
+
DEPENDENCIES
|
180
|
+
async-http
|
181
|
+
bootsnap (>= 1.4.2)
|
182
|
+
listen (>= 3.0.5, < 3.2)
|
183
|
+
quiq!
|
184
|
+
rails (~> 6.0.2, >= 6.0.2.1)
|
185
|
+
|
186
|
+
RUBY VERSION
|
187
|
+
ruby 2.7.0p0
|
188
|
+
|
189
|
+
BUNDLED WITH
|
190
|
+
2.1.2
|
data/testapp/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
data/testapp/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
4
|
+
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
7
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'async/http/internet'
|
5
|
+
|
6
|
+
class HttpJob < ApplicationJob
|
7
|
+
def perform(url)
|
8
|
+
uri = URI(url)
|
9
|
+
|
10
|
+
client = Async::HTTP::Internet.new
|
11
|
+
response = client.get(url)
|
12
|
+
Quiq.logger.info response.read
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
data/testapp/bin/bundle
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||=
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
71
|
+
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
73
|
+
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
75
|
+
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
77
|
+
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
79
|
+
|
80
|
+
requirement
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_bundler!
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
85
|
+
|
86
|
+
activate_bundler
|
87
|
+
end
|
88
|
+
|
89
|
+
def activate_bundler
|
90
|
+
gem_error = activation_error_handling do
|
91
|
+
gem "bundler", bundler_requirement
|
92
|
+
end
|
93
|
+
return if gem_error.nil?
|
94
|
+
require_error = activation_error_handling do
|
95
|
+
require "bundler/version"
|
96
|
+
end
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
99
|
+
exit 42
|
100
|
+
end
|
101
|
+
|
102
|
+
def activation_error_handling
|
103
|
+
yield
|
104
|
+
nil
|
105
|
+
rescue StandardError, LoadError => e
|
106
|
+
e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
m.load_bundler!
|
111
|
+
|
112
|
+
if m.invoked_as_script?
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
114
|
+
end
|
data/testapp/bin/rails
ADDED
data/testapp/bin/rake
ADDED
data/testapp/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to setup or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
puts "\n== Removing old logs and tempfiles =="
|
21
|
+
system! 'bin/rails log:clear tmp:clear'
|
22
|
+
|
23
|
+
puts "\n== Restarting application server =="
|
24
|
+
system! 'bin/rails restart'
|
25
|
+
end
|