sidekiq_publisher 1.5.0 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/CHANGELOG.md +13 -0
- data/Dockerfile +4 -0
- data/README.md +25 -0
- data/docker-compose.yml +43 -0
- data/lib/sidekiq_publisher.rb +0 -1
- data/lib/sidekiq_publisher/client.rb +1 -1
- data/lib/sidekiq_publisher/job.rb +9 -0
- data/lib/sidekiq_publisher/publisher.rb +2 -4
- data/lib/sidekiq_publisher/runner.rb +2 -4
- data/lib/sidekiq_publisher/tasks.rake +3 -0
- data/lib/sidekiq_publisher/testing.rb +25 -0
- data/lib/sidekiq_publisher/version.rb +1 -1
- data/lib/sidekiq_publisher/worker.rb +1 -6
- data/sidekiq_publisher.gemspec +1 -2
- metadata +11 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9995be94eaf8bfefa408b212d26f713137516b0ffd7846a47e51d8511a41383c
|
4
|
+
data.tar.gz: 8a23b6f5df56a8cc03569570f1943939b3ed54f9d916f8b4da0a3da51341aa65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 181dfdf294e496b3f2182692b37d62bd3d51749eda4ef57f4eb3ce05d092c622bef3f43a0b89eb84e7086651743bdfa3790434e07b45d3084874c7b27229d060
|
7
|
+
data.tar.gz: 878301b5e3f3f7d8b0f9bdd8078106aa71490ad887f351c5cd47e2ebca95f53d951d3ee71b0fcc89730ecd3e18cff1d15147f319709afaa446442e8978b1a426
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.5.5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# sidekiq_publisher
|
2
2
|
|
3
|
+
## v1.6.3
|
4
|
+
- Handle client middleware that returns false.
|
5
|
+
|
6
|
+
## v1.6.2
|
7
|
+
- Gracefully respond to `INT` and `TERM` process signals.
|
8
|
+
|
9
|
+
## v1.6.1
|
10
|
+
- Remove the `private_attr` top-level gem dependency.
|
11
|
+
|
12
|
+
## v1.6.0
|
13
|
+
- Support `Sidekiq::Testing` modes. This only applies to `SidekiqPublisher::Worker`
|
14
|
+
and not the `ActiveJob` adapter.
|
15
|
+
|
3
16
|
## v1.5.0
|
4
17
|
- Expand sidekiq support to v5.0.x-v6.0.x.
|
5
18
|
|
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -150,6 +150,31 @@ can be run with a rake task that is added via Railtie for Rails applications:
|
|
150
150
|
bundle exec rake sidekiq_publisher:publish
|
151
151
|
```
|
152
152
|
|
153
|
+
## Testing
|
154
|
+
|
155
|
+
### Sidekiq
|
156
|
+
|
157
|
+
When using sidekiq_publisher directly with Sidekiq workers, the testing modes
|
158
|
+
provided by Sidekiq are supported.
|
159
|
+
|
160
|
+
Require the `sidekiq_publisher/testing` file. (This should only be done in test!)
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
require "sidekiq_publisher/testing"
|
164
|
+
```
|
165
|
+
|
166
|
+
This file requires "sidekiq/testing" so there is no need to explictly require both.
|
167
|
+
Note that by default, Sidekiq sets the test mode to `fake` and stores jobs in a
|
168
|
+
`jobs` array for each worker class.
|
169
|
+
|
170
|
+
To have `SidekiqPublisher` continue to insert jobs into a table within tests
|
171
|
+
call `Sidekiq::Testing.disable!`.
|
172
|
+
|
173
|
+
### ActiveJob
|
174
|
+
|
175
|
+
When using the sidekiq_publisher adapter for `ActiveJob`, use the `ActiveJob`
|
176
|
+
test adapter if you want to run jobs inline during tests.
|
177
|
+
|
153
178
|
## Development
|
154
179
|
|
155
180
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
version: "3.4"
|
2
|
+
volumes:
|
3
|
+
bundle-volume:
|
4
|
+
shared-volume:
|
5
|
+
x-environment: &default-environment
|
6
|
+
PRYRC: /usr/src/app/.docker-pryrc
|
7
|
+
BUNDLE_IGNORE_CONFIG: 1
|
8
|
+
BUNDLE_DISABLE_SHARED_GEMS: "true"
|
9
|
+
PGUSER: postgres
|
10
|
+
PGHOST: sidekiq-publisher-postgres
|
11
|
+
PGPORT: 5432
|
12
|
+
PGDATABASE: sidekiq_publisher_test
|
13
|
+
REDIS_URL: redis://sidekiq-publisher-redis:6379
|
14
|
+
x-service: &default-service
|
15
|
+
build:
|
16
|
+
context: .
|
17
|
+
args:
|
18
|
+
- BUNDLE_EZCATER__JFROG__IO
|
19
|
+
volumes:
|
20
|
+
- .:/usr/src/gem
|
21
|
+
- bundle-volume:/usr/local/bundle:delegated
|
22
|
+
- shared-volume:/usr/src/shared:delegated
|
23
|
+
tty: true
|
24
|
+
stdin_open: true
|
25
|
+
services:
|
26
|
+
sidekiq-publisher-redis:
|
27
|
+
container_name: sidekiq-publisher-redis_1
|
28
|
+
image: redis:5.0.3-alpine
|
29
|
+
sidekiq-publisher-postgres:
|
30
|
+
container_name: sidekiq-publisher-postgres_1
|
31
|
+
image: postgres:10.6
|
32
|
+
environment:
|
33
|
+
POSTGRES_USER: postgres
|
34
|
+
POSTGRES_DB: sidekiq_publisher_test
|
35
|
+
sidekiq-publisher-console:
|
36
|
+
<<: *default-service
|
37
|
+
container_name: sidekiq-publisher-console_1
|
38
|
+
environment:
|
39
|
+
<<: *default-environment
|
40
|
+
command: bash
|
41
|
+
depends_on:
|
42
|
+
- sidekiq-publisher-redis
|
43
|
+
- sidekiq-publisher-postgres
|
data/lib/sidekiq_publisher.rb
CHANGED
@@ -18,6 +18,15 @@ module SidekiqPublisher
|
|
18
18
|
scope :published, -> { where.not(published_at: nil) }
|
19
19
|
scope :purgeable, -> { where("published_at < ?", Time.now.utc - job_retention_period) }
|
20
20
|
|
21
|
+
def self.create_job!(item)
|
22
|
+
create!(
|
23
|
+
job_class: item["class"].to_s,
|
24
|
+
args: item["args"],
|
25
|
+
run_at: item["at"],
|
26
|
+
queue: item["queue"]
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
21
30
|
def self.generate_sidekiq_jid
|
22
31
|
SecureRandom.hex(12)
|
23
32
|
end
|
@@ -5,10 +5,6 @@ require "active_support/core_ext/object/try"
|
|
5
5
|
|
6
6
|
module SidekiqPublisher
|
7
7
|
class Publisher
|
8
|
-
extend PrivateAttr
|
9
|
-
|
10
|
-
private_attr_reader :client, :job_class_cache
|
11
|
-
|
12
8
|
def initialize
|
13
9
|
@client = SidekiqPublisher::Client.new
|
14
10
|
@job_class_cache = {}
|
@@ -37,6 +33,8 @@ module SidekiqPublisher
|
|
37
33
|
|
38
34
|
private
|
39
35
|
|
36
|
+
attr_reader :client, :job_class_cache
|
37
|
+
|
40
38
|
def publish_batch(batch, items)
|
41
39
|
pushed_count = client.bulk_push(items)
|
42
40
|
published_count = update_jobs_as_published!(batch)
|
@@ -4,13 +4,9 @@ require "activerecord-postgres_pub_sub"
|
|
4
4
|
|
5
5
|
module SidekiqPublisher
|
6
6
|
class Runner
|
7
|
-
extend PrivateAttr
|
8
|
-
|
9
7
|
LISTENER_TIMEOUT_SECONDS = 60
|
10
8
|
CHANNEL_NAME = "sidekiq_publisher_job"
|
11
9
|
|
12
|
-
private_attr_reader :publisher
|
13
|
-
|
14
10
|
def self.run
|
15
11
|
new.run
|
16
12
|
end
|
@@ -32,6 +28,8 @@ module SidekiqPublisher
|
|
32
28
|
|
33
29
|
private
|
34
30
|
|
31
|
+
attr_reader :publisher
|
32
|
+
|
35
33
|
def listener_timeout
|
36
34
|
if Job.unpublished.exists?
|
37
35
|
SidekiqPublisher.logger&.warn(
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq_publisher"
|
4
|
+
require "sidekiq/testing"
|
5
|
+
|
6
|
+
module SidekiqPublisher
|
7
|
+
module Testing
|
8
|
+
def self.prepended(base)
|
9
|
+
base.singleton_class.public_send(:alias_method, :original_create_job!, :create_job!)
|
10
|
+
base.singleton_class.prepend(ClassMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def create_job!(item)
|
15
|
+
if Sidekiq::Testing.enabled?
|
16
|
+
item["class"].sidekiq_client_push(item)
|
17
|
+
else
|
18
|
+
original_create_job!(item)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
SidekiqPublisher::Job.prepend(SidekiqPublisher::Testing)
|
@@ -10,12 +10,7 @@ module SidekiqPublisher
|
|
10
10
|
|
11
11
|
module ClassMethods
|
12
12
|
def client_push(item)
|
13
|
-
SidekiqPublisher::Job.
|
14
|
-
job_class: item["class"].to_s,
|
15
|
-
args: item["args"],
|
16
|
-
run_at: item["at"],
|
17
|
-
queue: item["queue"]
|
18
|
-
)
|
13
|
+
SidekiqPublisher::Job.create_job!(item)
|
19
14
|
end
|
20
15
|
end
|
21
16
|
end
|
data/sidekiq_publisher.gemspec
CHANGED
@@ -54,10 +54,9 @@ Gem::Specification.new do |spec|
|
|
54
54
|
spec.add_development_dependency "rspec", "~> 3.4"
|
55
55
|
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
|
56
56
|
spec.add_development_dependency "shoulda-matchers"
|
57
|
-
spec.add_development_dependency "simplecov"
|
57
|
+
spec.add_development_dependency "simplecov", "< 0.18"
|
58
58
|
|
59
59
|
spec.add_runtime_dependency "activerecord-postgres_pub_sub", ">= 0.4.0"
|
60
60
|
spec.add_runtime_dependency "activesupport", ">= 5.1", "< 6.1"
|
61
|
-
spec.add_runtime_dependency "private_attr"
|
62
61
|
spec.add_runtime_dependency "sidekiq", ">= 5.0.4", "< 6.1"
|
63
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -196,16 +196,16 @@ dependencies:
|
|
196
196
|
name: simplecov
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
|
-
- - "
|
199
|
+
- - "<"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
201
|
+
version: '0.18'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
|
-
- - "
|
206
|
+
- - "<"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
208
|
+
version: '0.18'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: activerecord-postgres_pub_sub
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,20 +240,6 @@ dependencies:
|
|
240
240
|
- - "<"
|
241
241
|
- !ruby/object:Gem::Version
|
242
242
|
version: '6.1'
|
243
|
-
- !ruby/object:Gem::Dependency
|
244
|
-
name: private_attr
|
245
|
-
requirement: !ruby/object:Gem::Requirement
|
246
|
-
requirements:
|
247
|
-
- - ">="
|
248
|
-
- !ruby/object:Gem::Version
|
249
|
-
version: '0'
|
250
|
-
type: :runtime
|
251
|
-
prerelease: false
|
252
|
-
version_requirements: !ruby/object:Gem::Requirement
|
253
|
-
requirements:
|
254
|
-
- - ">="
|
255
|
-
- !ruby/object:Gem::Version
|
256
|
-
version: '0'
|
257
243
|
- !ruby/object:Gem::Dependency
|
258
244
|
name: sidekiq
|
259
245
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,11 +268,14 @@ extensions: []
|
|
282
268
|
extra_rdoc_files: []
|
283
269
|
files:
|
284
270
|
- ".codeclimate.yml"
|
271
|
+
- ".tool-versions"
|
285
272
|
- Appraisals
|
286
273
|
- CHANGELOG.md
|
274
|
+
- Dockerfile
|
287
275
|
- Gemfile
|
288
276
|
- LICENSE.txt
|
289
277
|
- README.md
|
278
|
+
- docker-compose.yml
|
290
279
|
- gemfiles/rails_5.1.gemfile
|
291
280
|
- gemfiles/rails_5.2.gemfile
|
292
281
|
- gemfiles/rails_5.2_sidekiq_5.0.gemfile
|
@@ -306,6 +295,7 @@ files:
|
|
306
295
|
- lib/sidekiq_publisher/report_unpublished_count.rb
|
307
296
|
- lib/sidekiq_publisher/runner.rb
|
308
297
|
- lib/sidekiq_publisher/tasks.rake
|
298
|
+
- lib/sidekiq_publisher/testing.rb
|
309
299
|
- lib/sidekiq_publisher/version.rb
|
310
300
|
- lib/sidekiq_publisher/worker.rb
|
311
301
|
- log/.gitkeep
|
@@ -330,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
320
|
- !ruby/object:Gem::Version
|
331
321
|
version: '0'
|
332
322
|
requirements: []
|
333
|
-
rubygems_version: 3.0.
|
323
|
+
rubygems_version: 3.0.3
|
334
324
|
signing_key:
|
335
325
|
specification_version: 4
|
336
326
|
summary: Publisher for enqueuing jobs to Sidekiq
|