lowkiq 1.2.2 → 1.2.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 +4 -4
- data/.github/workflows/rspec.yml +34 -0
- data/.gitignore +2 -1
- data/LICENSE.md +2 -2
- data/assets/app.js +82 -68
- data/lib/lowkiq/queue/actions.rb +1 -1
- data/lib/lowkiq/queue/queue.rb +49 -49
- data/lib/lowkiq/queue/queue_metrics.rb +2 -2
- data/lib/lowkiq/version.rb +1 -1
- data/lowkiq.gemspec +2 -2
- metadata +7 -10
- data/Gemfile.lock +0 -55
data/lib/lowkiq/queue/actions.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Lowkiq
|
|
|
12
12
|
def perform_all_jobs_now
|
|
13
13
|
@pool.with do |redis|
|
|
14
14
|
uredis = Utils::Redis.new redis
|
|
15
|
-
redis.multi do
|
|
15
|
+
redis.multi do |pipeline|
|
|
16
16
|
uredis.zresetscores @keys.all_ids_scored_by_perform_in_zset
|
|
17
17
|
@queue.shards.each do |shard|
|
|
18
18
|
uredis.zresetscores @keys.ids_scored_by_perform_in_zset(shard)
|
data/lib/lowkiq/queue/queue.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Lowkiq
|
|
|
14
14
|
|
|
15
15
|
def push(batch)
|
|
16
16
|
@pool.with do |redis|
|
|
17
|
-
redis.multi do
|
|
17
|
+
redis.multi do |pipeline|
|
|
18
18
|
batch.each do |job|
|
|
19
19
|
id = job.fetch(:id)
|
|
20
20
|
perform_in = job.fetch(:perform_in, @timestamp.call)
|
|
@@ -24,12 +24,12 @@ module Lowkiq
|
|
|
24
24
|
|
|
25
25
|
shard = id_to_shard id
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
pipeline.zadd @keys.all_ids_lex_zset, 0, id
|
|
28
|
+
pipeline.zadd @keys.all_ids_scored_by_perform_in_zset, perform_in, id, nx: true
|
|
29
|
+
pipeline.zadd @keys.all_ids_scored_by_retry_count_zset, retry_count, id, nx: true
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
pipeline.zadd @keys.ids_scored_by_perform_in_zset(shard), perform_in, id, nx: true
|
|
32
|
+
pipeline.zadd @keys.payloads_zset(id), score, Lowkiq.dump_payload.call(payload), nx: true
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -42,29 +42,29 @@ module Lowkiq
|
|
|
42
42
|
limit: [0, limit]
|
|
43
43
|
return [] if ids.empty?
|
|
44
44
|
|
|
45
|
-
res = redis.multi do |
|
|
46
|
-
|
|
45
|
+
res = redis.multi do |pipeline|
|
|
46
|
+
pipeline.hset @keys.processing_length_by_shard_hash, shard, ids.length
|
|
47
47
|
|
|
48
48
|
ids.each do |id|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
pipeline.zrem @keys.all_ids_lex_zset, id
|
|
50
|
+
pipeline.zrem @keys.ids_scored_by_perform_in_zset(shard), id
|
|
51
51
|
|
|
52
|
-
Script.zremhset
|
|
52
|
+
Script.zremhset pipeline,
|
|
53
53
|
@keys.all_ids_scored_by_perform_in_zset,
|
|
54
54
|
@keys.processing_ids_with_perform_in_hash(shard),
|
|
55
55
|
id
|
|
56
|
-
Script.zremhset
|
|
56
|
+
Script.zremhset pipeline,
|
|
57
57
|
@keys.all_ids_scored_by_retry_count_zset,
|
|
58
58
|
@keys.processing_ids_with_retry_count_hash(shard),
|
|
59
59
|
id
|
|
60
|
-
|
|
60
|
+
pipeline.rename @keys.payloads_zset(id),
|
|
61
61
|
@keys.processing_payloads_zset(id)
|
|
62
|
-
Script.hmove
|
|
62
|
+
Script.hmove pipeline,
|
|
63
63
|
@keys.errors_hash,
|
|
64
64
|
@keys.processing_errors_hash(shard),
|
|
65
65
|
id
|
|
66
66
|
end
|
|
67
|
-
processing_data_pipeline(
|
|
67
|
+
processing_data_pipeline(pipeline, shard, ids)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
res.shift 1 + ids.length * 6
|
|
@@ -75,7 +75,7 @@ module Lowkiq
|
|
|
75
75
|
def push_back(batch)
|
|
76
76
|
@pool.with do |redis|
|
|
77
77
|
timestamp = @timestamp.call
|
|
78
|
-
redis.multi do |
|
|
78
|
+
redis.multi do |pipeline|
|
|
79
79
|
batch.each do |job|
|
|
80
80
|
id = job.fetch(:id)
|
|
81
81
|
perform_in = job.fetch(:perform_in, timestamp)
|
|
@@ -87,14 +87,14 @@ module Lowkiq
|
|
|
87
87
|
|
|
88
88
|
shard = id_to_shard id
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
pipeline.zadd @keys.all_ids_lex_zset, 0, id
|
|
91
|
+
pipeline.zadd @keys.all_ids_scored_by_perform_in_zset, perform_in, id
|
|
92
|
+
pipeline.zadd @keys.all_ids_scored_by_retry_count_zset, retry_count, id
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
pipeline.zadd @keys.ids_scored_by_perform_in_zset(shard), perform_in, id
|
|
95
|
+
pipeline.zadd @keys.payloads_zset(id), payloads, nx: true
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
pipeline.hset @keys.errors_hash, id, error unless error.nil?
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
end
|
|
@@ -105,16 +105,16 @@ module Lowkiq
|
|
|
105
105
|
length = ids.length
|
|
106
106
|
|
|
107
107
|
@pool.with do |redis|
|
|
108
|
-
redis.multi do
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
redis.multi do |pipeline|
|
|
109
|
+
pipeline.del @keys.processing_ids_with_perform_in_hash(shard)
|
|
110
|
+
pipeline.del @keys.processing_ids_with_retry_count_hash(shard)
|
|
111
|
+
pipeline.del @keys.processing_errors_hash(shard)
|
|
112
112
|
ids.each do |id|
|
|
113
|
-
|
|
113
|
+
pipeline.del @keys.processing_payloads_zset(id)
|
|
114
114
|
end
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
pipeline.hdel @keys.processing_length_by_shard_hash, shard
|
|
116
|
+
pipeline.incrby @keys.processed_key, length if result == :success
|
|
117
|
+
pipeline.incrby @keys.failed_key, length if result == :fail
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
end
|
|
@@ -124,8 +124,8 @@ module Lowkiq
|
|
|
124
124
|
ids = redis.hkeys @keys.processing_ids_with_perform_in_hash(shard)
|
|
125
125
|
return [] if ids.empty?
|
|
126
126
|
|
|
127
|
-
res = redis.multi do |
|
|
128
|
-
processing_data_pipeline
|
|
127
|
+
res = redis.multi do |pipeline|
|
|
128
|
+
processing_data_pipeline pipeline, shard, ids
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
processing_data_build res, ids
|
|
@@ -135,7 +135,7 @@ module Lowkiq
|
|
|
135
135
|
def push_to_morgue(batch)
|
|
136
136
|
@pool.with do |redis|
|
|
137
137
|
timestamp = @timestamp.call
|
|
138
|
-
redis.multi do
|
|
138
|
+
redis.multi do |pipeline|
|
|
139
139
|
batch.each do |job|
|
|
140
140
|
id = job.fetch(:id)
|
|
141
141
|
payloads = job.fetch(:payloads).map do |(payload, score)|
|
|
@@ -144,11 +144,11 @@ module Lowkiq
|
|
|
144
144
|
error = Lowkiq.dump_error.call(job.fetch(:error, nil))
|
|
145
145
|
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
pipeline.zadd @keys.morgue_all_ids_lex_zset, 0, id
|
|
148
|
+
pipeline.zadd @keys.morgue_all_ids_scored_by_updated_at_zset, timestamp, id
|
|
149
|
+
pipeline.zadd @keys.morgue_payloads_zset(id), payloads, nx: true
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
pipeline.hset @keys.morgue_errors_hash, id, error unless error.nil?
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
154
|
end
|
|
@@ -156,12 +156,12 @@ module Lowkiq
|
|
|
156
156
|
|
|
157
157
|
def morgue_delete(ids)
|
|
158
158
|
@pool.with do |redis|
|
|
159
|
-
redis.multi do
|
|
159
|
+
redis.multi do |pipeline|
|
|
160
160
|
ids.each do |id|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
pipeline.zrem @keys.morgue_all_ids_lex_zset, id
|
|
162
|
+
pipeline.zrem @keys.morgue_all_ids_scored_by_updated_at_zset, id
|
|
163
|
+
pipeline.del @keys.morgue_payloads_zset(id)
|
|
164
|
+
pipeline.hdel @keys.morgue_errors_hash, id
|
|
165
165
|
end
|
|
166
166
|
end
|
|
167
167
|
end
|
|
@@ -169,15 +169,15 @@ module Lowkiq
|
|
|
169
169
|
|
|
170
170
|
def delete(ids)
|
|
171
171
|
@pool.with do |redis|
|
|
172
|
-
redis.multi do
|
|
172
|
+
redis.multi do |pipeline|
|
|
173
173
|
ids.each do |id|
|
|
174
174
|
shard = id_to_shard id
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
pipeline.zrem @keys.all_ids_lex_zset, id
|
|
176
|
+
pipeline.zrem @keys.all_ids_scored_by_perform_in_zset, id
|
|
177
|
+
pipeline.zrem @keys.all_ids_scored_by_retry_count_zset, id
|
|
178
|
+
pipeline.zrem @keys.ids_scored_by_perform_in_zset(shard), id
|
|
179
|
+
pipeline.del @keys.payloads_zset(id)
|
|
180
|
+
pipeline.hdel @keys.errors_hash, id
|
|
181
181
|
end
|
|
182
182
|
end
|
|
183
183
|
end
|
data/lib/lowkiq/version.rb
CHANGED
data/lowkiq.gemspec
CHANGED
|
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.name = "lowkiq"
|
|
7
7
|
spec.version = Lowkiq::VERSION
|
|
8
8
|
spec.authors = ["Mikhail Kuzmin"]
|
|
9
|
-
spec.email = ["
|
|
9
|
+
spec.email = ["m.kuzmin@darkleaf.ru"]
|
|
10
10
|
|
|
11
11
|
spec.summary = %q{Lowkiq}
|
|
12
12
|
spec.description = %q{Lowkiq}
|
|
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
35
|
spec.add_development_dependency "rspec-mocks", "~> 3.8"
|
|
36
36
|
spec.add_development_dependency "rack-test", "~> 1.1"
|
|
37
|
-
spec.add_development_dependency "pry-byebug", "
|
|
37
|
+
spec.add_development_dependency "pry-byebug", ">= 3.9.0"
|
|
38
38
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lowkiq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikhail Kuzmin
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: redis
|
|
@@ -138,29 +137,29 @@ dependencies:
|
|
|
138
137
|
name: pry-byebug
|
|
139
138
|
requirement: !ruby/object:Gem::Requirement
|
|
140
139
|
requirements:
|
|
141
|
-
- - "
|
|
140
|
+
- - ">="
|
|
142
141
|
- !ruby/object:Gem::Version
|
|
143
142
|
version: 3.9.0
|
|
144
143
|
type: :development
|
|
145
144
|
prerelease: false
|
|
146
145
|
version_requirements: !ruby/object:Gem::Requirement
|
|
147
146
|
requirements:
|
|
148
|
-
- - "
|
|
147
|
+
- - ">="
|
|
149
148
|
- !ruby/object:Gem::Version
|
|
150
149
|
version: 3.9.0
|
|
151
150
|
description: Lowkiq
|
|
152
151
|
email:
|
|
153
|
-
-
|
|
152
|
+
- m.kuzmin@darkleaf.ru
|
|
154
153
|
executables:
|
|
155
154
|
- lowkiq
|
|
156
155
|
extensions: []
|
|
157
156
|
extra_rdoc_files: []
|
|
158
157
|
files:
|
|
158
|
+
- ".github/workflows/rspec.yml"
|
|
159
159
|
- ".gitignore"
|
|
160
160
|
- ".rspec"
|
|
161
161
|
- CHANGELOG.md
|
|
162
162
|
- Gemfile
|
|
163
|
-
- Gemfile.lock
|
|
164
163
|
- LICENSE.md
|
|
165
164
|
- README.md
|
|
166
165
|
- README.ru.md
|
|
@@ -200,7 +199,6 @@ licenses:
|
|
|
200
199
|
- LGPL
|
|
201
200
|
- EULA
|
|
202
201
|
metadata: {}
|
|
203
|
-
post_install_message:
|
|
204
202
|
rdoc_options: []
|
|
205
203
|
require_paths:
|
|
206
204
|
- lib
|
|
@@ -215,8 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
215
213
|
- !ruby/object:Gem::Version
|
|
216
214
|
version: '0'
|
|
217
215
|
requirements: []
|
|
218
|
-
rubygems_version:
|
|
219
|
-
signing_key:
|
|
216
|
+
rubygems_version: 4.0.23
|
|
220
217
|
specification_version: 4
|
|
221
218
|
summary: Lowkiq
|
|
222
219
|
test_files: []
|
data/Gemfile.lock
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
lowkiq (1.2.1)
|
|
5
|
-
connection_pool (~> 2.2, >= 2.2.2)
|
|
6
|
-
rack (>= 1.5.0)
|
|
7
|
-
redis (>= 4.0.1, < 5)
|
|
8
|
-
|
|
9
|
-
GEM
|
|
10
|
-
remote: https://rubygems.org/
|
|
11
|
-
specs:
|
|
12
|
-
byebug (11.1.3)
|
|
13
|
-
coderay (1.1.3)
|
|
14
|
-
connection_pool (2.2.5)
|
|
15
|
-
diff-lcs (1.3)
|
|
16
|
-
method_source (1.0.0)
|
|
17
|
-
pry (0.13.1)
|
|
18
|
-
coderay (~> 1.1)
|
|
19
|
-
method_source (~> 1.0)
|
|
20
|
-
pry-byebug (3.9.0)
|
|
21
|
-
byebug (~> 11.0)
|
|
22
|
-
pry (~> 0.13.0)
|
|
23
|
-
rack (2.2.2)
|
|
24
|
-
rack-test (1.1.0)
|
|
25
|
-
rack (>= 1.0, < 3)
|
|
26
|
-
rake (12.3.3)
|
|
27
|
-
redis (4.7.1)
|
|
28
|
-
rspec (3.9.0)
|
|
29
|
-
rspec-core (~> 3.9.0)
|
|
30
|
-
rspec-expectations (~> 3.9.0)
|
|
31
|
-
rspec-mocks (~> 3.9.0)
|
|
32
|
-
rspec-core (3.9.1)
|
|
33
|
-
rspec-support (~> 3.9.1)
|
|
34
|
-
rspec-expectations (3.9.0)
|
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
36
|
-
rspec-support (~> 3.9.0)
|
|
37
|
-
rspec-mocks (3.9.1)
|
|
38
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
|
-
rspec-support (~> 3.9.0)
|
|
40
|
-
rspec-support (3.9.2)
|
|
41
|
-
|
|
42
|
-
PLATFORMS
|
|
43
|
-
ruby
|
|
44
|
-
|
|
45
|
-
DEPENDENCIES
|
|
46
|
-
bundler (~> 2.1)
|
|
47
|
-
lowkiq!
|
|
48
|
-
pry-byebug (~> 3.9.0)
|
|
49
|
-
rack-test (~> 1.1)
|
|
50
|
-
rake (~> 12.3.0)
|
|
51
|
-
rspec (~> 3.0)
|
|
52
|
-
rspec-mocks (~> 3.8)
|
|
53
|
-
|
|
54
|
-
BUNDLED WITH
|
|
55
|
-
2.2.22
|