disqualified 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +165 -0
- data/README.md +40 -0
- data/app/assets/config/disqualified_manifest.js +0 -0
- data/app/models/disqualified/base_record.rb +2 -0
- data/app/models/disqualified/record.rb +3 -0
- data/config/routes.rb +2 -0
- data/exe/disqualified +6 -0
- data/lib/disqualified/cli.rb +66 -0
- data/lib/disqualified/engine.rb +4 -0
- data/lib/disqualified/job.rb +24 -0
- data/lib/disqualified/logging.rb +7 -0
- data/lib/disqualified/main.rb +79 -0
- data/lib/disqualified/pool.rb +69 -0
- data/lib/disqualified/server_configuration.rb +55 -0
- data/lib/disqualified/version.rb +3 -0
- data/lib/disqualified.rb +17 -0
- data/lib/generators/disqualified/install/USAGE +8 -0
- data/lib/generators/disqualified/install/install_generator.rb +8 -0
- data/lib/generators/disqualified/install/templates/20220703062536_create_disqualified_jobs.rb +16 -0
- data/lib/tasks/disqualified_tasks.rake +4 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a30c5111164b062b8615ff07beb0904fca3c38b1c279e92a09c31e30fccecb9f
|
4
|
+
data.tar.gz: ee299e3d06536fcb745f14281b68599c89c1f72bedfa70892d76efd9f2953324
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 282d988287c0d221ad5e0a05d0c386d0f1869cca2e617b8d4ad4e87743e46b0f0467232059e1e7ac32eedb3a162794b710564f3337a00d54adbbf98edb781506
|
7
|
+
data.tar.gz: 02e1a353c89adcb35ff1bce7960265a0576280b280de404c2532ecddea8affd496e4cb3f58ca93c15a27651150a70f8496bb9d359cf5366c5c5c68c1c8616112
|
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Disqualified
|
2
|
+
|
3
|
+
I wanted a small background job framework that used SQLite as the backend.
|
4
|
+
|
5
|
+
Since SQLite doesn't have any features like Postgres' `LISTEN`/`NOTIFY`,
|
6
|
+
Disqualified resorts to polling the database. This might _disqualify_ it as an
|
7
|
+
option for you, but it works well enough for my workload.
|
8
|
+
|
9
|
+
Disqualified only works with Rails. It does not work with ActiveJob.
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Run `bundle exec disqualified --help`
|
15
|
+
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Run this in your shell, in your Rails app.
|
20
|
+
|
21
|
+
```bash
|
22
|
+
bundle add disqualified
|
23
|
+
bundle exec rails generate disqualified:install
|
24
|
+
bundle binstub disqualified
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
PRs are welcome! Please confirm the change with me before you start working;
|
31
|
+
some features might be better off as a plugin or as a fork.
|
32
|
+
|
33
|
+
When submitting a PR, and if you prefer, please `Allow edits from maintainers`.
|
34
|
+
This will help get your contributions merged in a bit faster.
|
35
|
+
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the
|
40
|
+
[LGPL v3 License](https://opensource.org/licenses/LGPL-3.0).
|
File without changes
|
data/config/routes.rb
ADDED
data/exe/disqualified
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
class Disqualified::CLI
|
2
|
+
include Disqualified::Logging
|
3
|
+
|
4
|
+
def self.run
|
5
|
+
cli = new(ARGV)
|
6
|
+
cli.run
|
7
|
+
end
|
8
|
+
|
9
|
+
class ServerEngine < Rails::Engine
|
10
|
+
config.before_initialize do
|
11
|
+
Disqualified.server_options = Disqualified::ServerConfiguration.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(argv)
|
16
|
+
@original_argv = argv
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
require File.join(Dir.pwd, "config/environment")
|
21
|
+
|
22
|
+
option_parser.parse(@original_argv)
|
23
|
+
|
24
|
+
Disqualified.server_options.to_h => {delay_range:, error_hooks:, logger:, pool_size:}
|
25
|
+
|
26
|
+
logger.info { ' ____ _ ___ _____ __' }
|
27
|
+
logger.info { ' / __ \(_)________ ___ ______ _/ (_) __(_)__ ____/ /' }
|
28
|
+
logger.info { ' / / / / / ___/ __ `/ / / / __ `/ / / /_/ / _ \/ __ /' }
|
29
|
+
logger.info { ' / /_/ / (__ ) /_/ / /_/ / /_/ / / / __/ / __/ /_/ /' }
|
30
|
+
logger.info { '/_____/_/____/\__, /\__,_/\__,_/_/_/_/ /_/\___/\__,_/' }
|
31
|
+
logger.info { ' /_/' + "v#{Disqualified::VERSION}".rjust(32, " ") }
|
32
|
+
logger.info { "#{Disqualified.server_options.to_s}" }
|
33
|
+
|
34
|
+
pool = Disqualified::Pool.new(delay_range:, pool_size:, logger:) do |args|
|
35
|
+
args => { promise_index:, running: }
|
36
|
+
logger.debug { format_log("[Disqualified::CLI#run <block>] ##{promise_index}") }
|
37
|
+
Disqualified::Main.new(error_hooks:, logger:).call
|
38
|
+
end
|
39
|
+
pool.run!
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def option_parser
|
45
|
+
@option_parser ||= OptionParser.new do |opts|
|
46
|
+
opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
|
47
|
+
|
48
|
+
opts.on("--delay-low SECONDS", Numeric, "Default: #{Disqualified.server_options.delay_low}") do |value|
|
49
|
+
Disqualified.server_options.delay_low = value
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on("--delay-high SECONDS", Numeric, "Default: #{Disqualified.server_options.delay_high}") do |value|
|
53
|
+
Disqualified.server_options.delay_high = value
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on("--pool COUNT", Integer, "Default: #{Disqualified.server_options.pool_size}") do |value|
|
57
|
+
Disqualified.server_options.pool_size = value
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on("-h", "--help", "Prints this help") do
|
61
|
+
puts opts
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Disqualified::Job
|
2
|
+
def self.included(base)
|
3
|
+
base.extend ClassMethods
|
4
|
+
end
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def perform_at(the_time, *args)
|
8
|
+
Disqualified::Record.create(
|
9
|
+
handler: self.name,
|
10
|
+
arguments: JSON.dump(args),
|
11
|
+
queue: "default",
|
12
|
+
run_at: the_time
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def perform_async(*args)
|
17
|
+
perform_at(Time.now, *args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def perform_in(delay, *args)
|
21
|
+
perform_at(Time.now + delay, *args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class Disqualified::Main
|
2
|
+
include Disqualified::Logging
|
3
|
+
|
4
|
+
def initialize(error_hooks:, logger:)
|
5
|
+
@error_hooks = error_hooks
|
6
|
+
@logger = logger
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
run_id = SecureRandom.uuid
|
11
|
+
|
12
|
+
Rails.application.executor.wrap do
|
13
|
+
# Claim a job
|
14
|
+
claimed_count =
|
15
|
+
Disqualified::Record
|
16
|
+
.where(finished_at: nil, run_at: (..Time.now), locked_by: nil)
|
17
|
+
.order(run_at: :asc)
|
18
|
+
.limit(1)
|
19
|
+
.update_all(locked_by: run_id, locked_at: Time.now, updated_at: Time.now, attempts: Arel.sql("attempts + 1"))
|
20
|
+
|
21
|
+
@logger.debug { format_log("[Disqualified::Main#run] [Runner #{run_id}] Claimed #{claimed_count}") }
|
22
|
+
|
23
|
+
next if claimed_count == 0
|
24
|
+
|
25
|
+
# Find the job that we claimed; quit early if none was claimed
|
26
|
+
job = Disqualified::Record.find_by!(locked_by: run_id)
|
27
|
+
|
28
|
+
begin
|
29
|
+
# Deserialize job
|
30
|
+
handler_class = job.handler.constantize
|
31
|
+
arguments = JSON.parse(job.arguments)
|
32
|
+
|
33
|
+
begin
|
34
|
+
@logger.info do
|
35
|
+
format_log("[#{run_id}] Running `#{job.handler}' with #{arguments.size} argument(s)")
|
36
|
+
end
|
37
|
+
rescue
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
# Run the job
|
42
|
+
handler = handler_class.new
|
43
|
+
handler.perform(*arguments)
|
44
|
+
|
45
|
+
finish(job)
|
46
|
+
|
47
|
+
begin
|
48
|
+
@logger.info do
|
49
|
+
format_log("[#{run_id}] Done")
|
50
|
+
end
|
51
|
+
rescue
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
rescue => e
|
55
|
+
@error_hooks.each do |hook|
|
56
|
+
hook.call(e)
|
57
|
+
rescue
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
@logger.error { format_log("[Disqualified::Main#run] [Runner #{run_id}] Rescued Record ##{job&.id}") }
|
61
|
+
requeue(job)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def finish(job)
|
69
|
+
job.update!(locked_by: nil, locked_at: nil, finished_at: Time.now)
|
70
|
+
end
|
71
|
+
|
72
|
+
def requeue(job)
|
73
|
+
# Formula from the Sidekiq wiki
|
74
|
+
retry_count = job.attempts - 1
|
75
|
+
sleep = (retry_count**4) + 15 + (rand(10) * (retry_count + 1))
|
76
|
+
@logger.error { format_log("[Disqualified::Main#requeue] Sleeping job for ##{sleep} seconds") }
|
77
|
+
job.update!(locked_by: nil, locked_at: nil, run_at: Time.now + sleep)
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
class Disqualified::Pool
|
2
|
+
include Disqualified::Logging
|
3
|
+
|
4
|
+
def initialize(delay_range:, logger:, pool_size:, &task)
|
5
|
+
@delay_range = delay_range
|
6
|
+
@logger = logger
|
7
|
+
@pool_size = pool_size
|
8
|
+
@task = task
|
9
|
+
@running = Concurrent::AtomicBoolean.new(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
def run!
|
13
|
+
Concurrent::Promises
|
14
|
+
.zip(*pool)
|
15
|
+
.rescue { |error| handle_error(error) }
|
16
|
+
.run
|
17
|
+
.value!
|
18
|
+
end
|
19
|
+
|
20
|
+
def pool
|
21
|
+
@pool ||=
|
22
|
+
@pool_size.times.map do |promise_index|
|
23
|
+
initial_delay = random_interval * promise_index / @pool_size
|
24
|
+
Concurrent::Promises
|
25
|
+
.schedule(initial_delay) do
|
26
|
+
repeat(promise_index:, schedule: false, previous_delay: initial_delay)
|
27
|
+
end
|
28
|
+
.rescue { |error| handle_error(error) }
|
29
|
+
.run
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def repeat(promise_index:, schedule:, previous_delay:)
|
34
|
+
if @running.false?
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
interval =
|
39
|
+
if schedule
|
40
|
+
random_interval
|
41
|
+
else
|
42
|
+
0
|
43
|
+
end
|
44
|
+
|
45
|
+
@logger.debug { format_log("[Disqualified::Pool#repeat(#{promise_index})] Interval #{interval}") }
|
46
|
+
|
47
|
+
args = {
|
48
|
+
promise_index:,
|
49
|
+
running: @running
|
50
|
+
}
|
51
|
+
|
52
|
+
Concurrent::Promises
|
53
|
+
.schedule(interval, args, &@task)
|
54
|
+
.then { repeat(promise_index:, schedule: true, previous_delay: interval) }
|
55
|
+
.rescue { |error| handle_error(error) }
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def random_interval
|
61
|
+
rand(@delay_range)
|
62
|
+
end
|
63
|
+
|
64
|
+
def handle_error(error)
|
65
|
+
pp error
|
66
|
+
puts "Gracefully quitting..."
|
67
|
+
@running.make_false
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Disqualified
|
2
|
+
class << self
|
3
|
+
attr_accessor :server_options
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure_server
|
7
|
+
if server_options
|
8
|
+
yield server_options
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Disqualified::ServerConfiguration
|
14
|
+
def initialize
|
15
|
+
self.delay_high = 5.0
|
16
|
+
self.delay_low = 1.0
|
17
|
+
self.logger = Rails.logger
|
18
|
+
self.pool_size = 5
|
19
|
+
self.pwd = Dir.pwd
|
20
|
+
self.error_hooks = []
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_accessor :delay_high
|
24
|
+
attr_accessor :delay_low
|
25
|
+
attr_accessor :error_hooks
|
26
|
+
attr_accessor :logger
|
27
|
+
attr_accessor :pool_size
|
28
|
+
attr_accessor :pwd
|
29
|
+
|
30
|
+
private :error_hooks=
|
31
|
+
|
32
|
+
def delay_range
|
33
|
+
delay_low.to_f..delay_high.to_f
|
34
|
+
end
|
35
|
+
|
36
|
+
def on_error(&block)
|
37
|
+
error_hooks.push(block)
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_h
|
41
|
+
{
|
42
|
+
delay_high:,
|
43
|
+
delay_low:,
|
44
|
+
delay_range:,
|
45
|
+
error_hooks:,
|
46
|
+
logger:,
|
47
|
+
pool_size:,
|
48
|
+
pwd:
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
"{ delay: #{delay_range}, pool_size: #{pool_size}, error_hooks_size: #{error_hooks.size} }"
|
54
|
+
end
|
55
|
+
end
|
data/lib/disqualified.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
require "concurrent"
|
4
|
+
require "rails"
|
5
|
+
|
6
|
+
require_relative "disqualified/logging"
|
7
|
+
|
8
|
+
require_relative "disqualified/engine"
|
9
|
+
require_relative "disqualified/job"
|
10
|
+
require_relative "disqualified/main"
|
11
|
+
require_relative "disqualified/pool"
|
12
|
+
require_relative "disqualified/server_configuration"
|
13
|
+
require_relative "disqualified/version"
|
14
|
+
|
15
|
+
module Disqualified
|
16
|
+
# Your code goes here...
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateDisqualifiedJobs < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :disqualified_jobs do |t|
|
4
|
+
t.string :handler, null: false
|
5
|
+
t.text :arguments, null: false
|
6
|
+
t.string :queue, null: false
|
7
|
+
t.datetime :run_at, null: false
|
8
|
+
t.integer :attempts, null: false, default: 0
|
9
|
+
t.datetime :locked_at
|
10
|
+
t.string :locked_by
|
11
|
+
t.datetime :finished_at
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: disqualified
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zach Ahn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 7.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 7.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocktail
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: standard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- engineering@zachahn.com
|
58
|
+
executables:
|
59
|
+
- disqualified
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- app/assets/config/disqualified_manifest.js
|
66
|
+
- app/models/disqualified/base_record.rb
|
67
|
+
- app/models/disqualified/record.rb
|
68
|
+
- config/routes.rb
|
69
|
+
- exe/disqualified
|
70
|
+
- lib/disqualified.rb
|
71
|
+
- lib/disqualified/cli.rb
|
72
|
+
- lib/disqualified/engine.rb
|
73
|
+
- lib/disqualified/job.rb
|
74
|
+
- lib/disqualified/logging.rb
|
75
|
+
- lib/disqualified/main.rb
|
76
|
+
- lib/disqualified/pool.rb
|
77
|
+
- lib/disqualified/server_configuration.rb
|
78
|
+
- lib/disqualified/version.rb
|
79
|
+
- lib/generators/disqualified/install/USAGE
|
80
|
+
- lib/generators/disqualified/install/install_generator.rb
|
81
|
+
- lib/generators/disqualified/install/templates/20220703062536_create_disqualified_jobs.rb
|
82
|
+
- lib/tasks/disqualified_tasks.rake
|
83
|
+
homepage: https://github.com/zachahn/disqualified
|
84
|
+
licenses:
|
85
|
+
- LGPL-3.0-only
|
86
|
+
metadata:
|
87
|
+
homepage_uri: https://github.com/zachahn/disqualified
|
88
|
+
source_code_uri: https://github.com/zachahn/disqualified
|
89
|
+
changelog_uri: https://github.com/zachahn/disqualified/blob/main/CHANGELOG.md
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 3.1.0
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubygems_version: 3.3.7
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: A background job processor tuned for SQLite
|
109
|
+
test_files: []
|