sidekiq_publisher 1.6.2 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/Appraisals +12 -0
- data/CHANGELOG.md +12 -0
- data/Dockerfile +4 -0
- data/README.md +28 -0
- data/docker-compose.yml +43 -0
- data/gemfiles/rails_5.2_sidekiq_6.1.gemfile +9 -0
- data/gemfiles/rails_6.0_sidekiq_6.1.gemfile +9 -0
- data/lib/sidekiq_publisher.rb +4 -0
- data/lib/sidekiq_publisher/client.rb +1 -1
- data/lib/sidekiq_publisher/datadog_apm.rb +106 -0
- data/lib/sidekiq_publisher/exception_reporter.rb +15 -0
- data/lib/sidekiq_publisher/instrumenter.rb +13 -0
- data/lib/sidekiq_publisher/job.rb +4 -3
- data/lib/sidekiq_publisher/metrics_reporter.rb +40 -0
- data/lib/sidekiq_publisher/publisher.rb +25 -24
- data/lib/sidekiq_publisher/report_unpublished_count.rb +3 -4
- data/lib/sidekiq_publisher/runner.rb +23 -14
- data/lib/sidekiq_publisher/version.rb +1 -1
- data/sidekiq_publisher.gemspec +3 -2
- metadata +35 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91e1f28973451bbee0a4b0d099e417707d0413ba475c2f7530d07d34f9e74b1f
|
4
|
+
data.tar.gz: a9dd797b6193ef3a183f318afcc7582c375c0b2d374eac688203ac3eb3cf3f48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 434a5f016d1ab9a082c6d786d002a8b1bacac7cc3ed4832d60ffa47678f9e81112e7ff0bb8bd3002a50cba4a3c99ba803a7e2fdbbc93e9805008a6a04073228f
|
7
|
+
data.tar.gz: 202cb6eaf93e710379917e421167ba8bc1a3dc40634404f83595e8f3519956ea03e177ffb5e92407cfa61ce49a11a9748bdc3571eb4684a20cdbd2eace5080bf
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @ezcater/core-platform @tjwp
|
data/Appraisals
CHANGED
@@ -29,6 +29,12 @@ appraise "rails-5.2-sidekiq-6.0" do
|
|
29
29
|
gem "sidekiq", "~> 6.0.1"
|
30
30
|
end
|
31
31
|
|
32
|
+
appraise "rails-5.2-sidekiq-6.1" do
|
33
|
+
gem "activejob", "~> 5.2.0"
|
34
|
+
gem "activesupport", "~> 5.2.0"
|
35
|
+
gem "sidekiq", "~> 6.1.0"
|
36
|
+
end
|
37
|
+
|
32
38
|
appraise "rails-6.0-sidekiq-5.2" do
|
33
39
|
gem "activejob", "~> 6.0.0"
|
34
40
|
gem "activesupport", "~> 6.0.0"
|
@@ -40,3 +46,9 @@ appraise "rails-6.0-sidekiq-6.0" do
|
|
40
46
|
gem "activesupport", "~> 6.0.0"
|
41
47
|
gem "sidekiq", "~> 6.0.1"
|
42
48
|
end
|
49
|
+
|
50
|
+
appraise "rails-6.0-sidekiq-6.1" do
|
51
|
+
gem "activejob", "~> 6.0.0"
|
52
|
+
gem "activesupport", "~> 6.0.0"
|
53
|
+
gem "sidekiq", "~> 6.1.0"
|
54
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# sidekiq_publisher
|
2
2
|
|
3
|
+
## v1.7.0
|
4
|
+
- Add instrumentation using `ActiveSupport::Notifications`.
|
5
|
+
- Reimplement `metrics_reporter` and `exception_reporter` support using
|
6
|
+
`ActiveSupport::Subscriber`.
|
7
|
+
- Add optional integration with Datadog APM.
|
8
|
+
|
9
|
+
## v1.6.4
|
10
|
+
- Expand sidekiq support to v5.0.x-v6.x.x.
|
11
|
+
|
12
|
+
## v1.6.3
|
13
|
+
- Handle client middleware that returns false.
|
14
|
+
|
3
15
|
## v1.6.2
|
4
16
|
- Gracefully respond to `INT` and `TERM` process signals.
|
5
17
|
|
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -72,6 +72,34 @@ SidekiqPublisher::ReportUnpublishedCount.call
|
|
72
72
|
It is recommended to call this method periodically using something like
|
73
73
|
cron or [clockwork](https://github.com/Rykian/clockwork).
|
74
74
|
|
75
|
+
## Instrumentation
|
76
|
+
|
77
|
+
Instrumentation of this library is implemented using
|
78
|
+
[ActiveSupport::Notifications](https://api.rubyonrails.org/classes/ActiveSupport/Notifications.html).
|
79
|
+
|
80
|
+
The support for the configurable [metrics_reporter](lib/sidekiq_publisher/metrics_reporter.rb) and
|
81
|
+
[exception_reporter](lib/sidekiq_publisher/exception_reporter.rb) options is implemented using
|
82
|
+
[ActiveSupport::Subscriber](https://api.rubyonrails.org/classes/ActiveSupport/Subscriber.html).
|
83
|
+
|
84
|
+
If an alternate integration is required for metrics or error reporting then it can be implemented using outside this
|
85
|
+
library based on these examples.
|
86
|
+
|
87
|
+
### Tracing
|
88
|
+
|
89
|
+
The instrumentation in the library also supports integration with application tracing products, such as
|
90
|
+
[Datadog APM](https://www.datadoghq.com/product/apm/).
|
91
|
+
|
92
|
+
There is an optional integration with Datadog APM that can be required:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
require "sidekiq_publisher/datadog_apm"
|
96
|
+
```
|
97
|
+
|
98
|
+
This file must be required in addition including the `sidekiq_publisher` gem or requiring `sidekiq_publisher`.
|
99
|
+
|
100
|
+
This integration covers all of the sections of the library that are instrumented and serves an
|
101
|
+
[example](lib/sidekiq_publisher/datadog_apm) for implementing trace reporting for other products outside this library.
|
102
|
+
|
75
103
|
## Usage
|
76
104
|
|
77
105
|
### ActiveJob Adapter
|
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.9-alpine
|
29
|
+
sidekiq-publisher-postgres:
|
30
|
+
container_name: sidekiq-publisher-postgres_1
|
31
|
+
image: postgres:11.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
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support"
|
3
4
|
require "sidekiq_publisher/version"
|
5
|
+
require "sidekiq_publisher/instrumenter"
|
6
|
+
require "sidekiq_publisher/metrics_reporter"
|
7
|
+
require "sidekiq_publisher/exception_reporter"
|
4
8
|
require "sidekiq_publisher/report_unpublished_count"
|
5
9
|
require "sidekiq_publisher/job"
|
6
10
|
require "sidekiq_publisher/worker"
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/subscriber"
|
4
|
+
require "ddtrace"
|
5
|
+
|
6
|
+
module SidekiqPublisher
|
7
|
+
module DatadogAPM
|
8
|
+
OPERATION = "sidekiq_publisher"
|
9
|
+
|
10
|
+
class << self
|
11
|
+
attr_writer :service
|
12
|
+
|
13
|
+
def service
|
14
|
+
@service || "sidekiq-publisher"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Subscriber
|
19
|
+
def self.subscribe_to(pattern)
|
20
|
+
ActiveSupport::Notifications.subscribe(pattern, new)
|
21
|
+
end
|
22
|
+
|
23
|
+
def finish(_name, _id, payload)
|
24
|
+
finish_span(payload)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def start_span(operation, payload, resource = nil)
|
30
|
+
resource ||= operation
|
31
|
+
payload[:datadog_span] = Datadog.tracer.trace(operation, service: service, resource: resource)
|
32
|
+
end
|
33
|
+
|
34
|
+
def start_primary_span(resource, payload)
|
35
|
+
start_span(OPERATION, payload, resource)
|
36
|
+
end
|
37
|
+
|
38
|
+
def finish_span(payload)
|
39
|
+
payload[:datadog_span]&.set_error(payload[:exception_object]) if payload.key?(:exception_object)
|
40
|
+
payload[:datadog_span]&.finish
|
41
|
+
end
|
42
|
+
|
43
|
+
def service
|
44
|
+
SidekiqPublisher::DatadogAPM.service
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class ListenerSubscriber < Subscriber
|
49
|
+
def start(_name, _id, payload)
|
50
|
+
start_primary_span("listener.timeout", payload)
|
51
|
+
end
|
52
|
+
|
53
|
+
subscribe_to "timeout.listener.sidekiq_publisher"
|
54
|
+
end
|
55
|
+
|
56
|
+
class RunnerSubscriber < Subscriber
|
57
|
+
def start(name, _id, payload)
|
58
|
+
op_name = name.split(".").first
|
59
|
+
start_primary_span("publisher.#{op_name}", payload)
|
60
|
+
end
|
61
|
+
|
62
|
+
subscribe_to "start.publisher.sidekiq_publisher"
|
63
|
+
subscribe_to "notify.publisher.sidekiq_publisher"
|
64
|
+
subscribe_to "timeout.publisher.sidekiq_publisher"
|
65
|
+
end
|
66
|
+
|
67
|
+
class PublisherSubscriber < Subscriber
|
68
|
+
def start(name, _id, payload)
|
69
|
+
op_name = name.split(".").first
|
70
|
+
start_span("publisher.#{op_name}", payload)
|
71
|
+
end
|
72
|
+
|
73
|
+
def finish(name, id, payload)
|
74
|
+
payload[:datadog_span]&.set_tag(:published_count, payload[:published_count]) if payload.key?(:published_count)
|
75
|
+
super
|
76
|
+
end
|
77
|
+
|
78
|
+
subscribe_to "publish_batch.publisher.sidekiq_publisher"
|
79
|
+
subscribe_to "enqueue_batch.publisher.sidekiq_publisher"
|
80
|
+
end
|
81
|
+
|
82
|
+
class JobSubscriber < Subscriber
|
83
|
+
def start(_name, _id, payload)
|
84
|
+
start_span("job.purge", payload)
|
85
|
+
end
|
86
|
+
|
87
|
+
def finish(_name, _id, payload)
|
88
|
+
payload[:datadog_span]&.set_tag(:purged_count, payload[:purged_count]) if payload.key?(:purged_count)
|
89
|
+
|
90
|
+
super
|
91
|
+
end
|
92
|
+
|
93
|
+
subscribe_to "purge.job.sidekiq_publisher"
|
94
|
+
end
|
95
|
+
|
96
|
+
# This subscriber is different from the classes above because it is an ActiveSupport::Subscriber
|
97
|
+
# and responds to the error(.publisher.sidekiq_publisher) event.
|
98
|
+
class PublisherErrorSubscriber < ActiveSupport::Subscriber
|
99
|
+
def error(event)
|
100
|
+
Datadog.tracer.active_span&.set_error(event.payload[:exception_object])
|
101
|
+
end
|
102
|
+
|
103
|
+
attach_to "publisher.sidekiq_publisher"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/subscriber"
|
4
|
+
|
5
|
+
module SidekiqPublisher
|
6
|
+
module ExceptionReporter
|
7
|
+
class PublisherErrorSubscriber < ActiveSupport::Subscriber
|
8
|
+
def error(event)
|
9
|
+
SidekiqPublisher.exception_reporter&.call(event.payload[:exception_object])
|
10
|
+
end
|
11
|
+
|
12
|
+
attach_to "publisher.sidekiq_publisher"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/notifications"
|
4
|
+
|
5
|
+
module SidekiqPublisher
|
6
|
+
class Instrumenter
|
7
|
+
NAMESPACE = "sidekiq_publisher"
|
8
|
+
|
9
|
+
def instrument(event_name, payload = {}, &block)
|
10
|
+
ActiveSupport::Notifications.instrument("#{event_name}.#{NAMESPACE}", payload, &block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -39,11 +39,12 @@ module SidekiqPublisher
|
|
39
39
|
where(id: ids).update_all(published_at: Time.now.utc)
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.purge_expired_published!
|
42
|
+
def self.purge_expired_published!(instrumenter: Instrumenter.new)
|
43
43
|
SidekiqPublisher.logger.info("#{name} purging expired published jobs.")
|
44
|
-
count =
|
44
|
+
count = instrumenter.instrument("purge.job") do |notification|
|
45
|
+
notification[:purged_count] = purgeable.delete_all
|
46
|
+
end
|
45
47
|
SidekiqPublisher.logger.info("#{name} purged #{count} expired published jobs.")
|
46
|
-
SidekiqPublisher.metrics_reporter.try(:count, "sidekiq_publisher.purged", count)
|
47
48
|
end
|
48
49
|
|
49
50
|
def self.unpublished_batches(batch_size: SidekiqPublisher.batch_size)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/subscriber"
|
4
|
+
|
5
|
+
module SidekiqPublisher
|
6
|
+
module MetricsReporter
|
7
|
+
class Subscriber < ActiveSupport::Subscriber
|
8
|
+
private
|
9
|
+
|
10
|
+
def count(metric, value)
|
11
|
+
SidekiqPublisher.metrics_reporter&.try(:count, metric, value) unless value.nil?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class PublisherSubscriber < Subscriber
|
16
|
+
def enqueue_batch(event)
|
17
|
+
count("sidekiq_publisher.published", event.payload[:published_count])
|
18
|
+
end
|
19
|
+
|
20
|
+
attach_to "publisher.sidekiq_publisher"
|
21
|
+
end
|
22
|
+
|
23
|
+
class JobSubscriber < Subscriber
|
24
|
+
def purge(event)
|
25
|
+
count("sidekiq_publisher.purged", event.payload[:purged_count])
|
26
|
+
end
|
27
|
+
|
28
|
+
attach_to "job.sidekiq_publisher"
|
29
|
+
end
|
30
|
+
|
31
|
+
class UnpublishedSubscriber < Subscriber
|
32
|
+
def unpublished(event)
|
33
|
+
SidekiqPublisher.metrics_reporter&.
|
34
|
+
try(:gauge, "sidekiq_publisher.unpublished_count", event.payload[:unpublished_count])
|
35
|
+
end
|
36
|
+
|
37
|
+
attach_to "reporter.sidekiq_publisher"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -5,26 +5,31 @@ require "active_support/core_ext/object/try"
|
|
5
5
|
|
6
6
|
module SidekiqPublisher
|
7
7
|
class Publisher
|
8
|
-
def initialize
|
8
|
+
def initialize(instrumenter: Instrumenter.new)
|
9
|
+
@instrumenter = instrumenter
|
9
10
|
@client = SidekiqPublisher::Client.new
|
10
11
|
@job_class_cache = {}
|
11
12
|
end
|
12
13
|
|
13
14
|
def publish
|
14
15
|
Job.unpublished_batches do |batch|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
instrumenter.instrument("publish_batch.publisher") do
|
17
|
+
items = batch.map do |job|
|
18
|
+
{
|
19
|
+
"jid" => job[:job_id],
|
20
|
+
"class" => lookup_job_class(job[:job_class]),
|
21
|
+
"args" => job[:args],
|
22
|
+
"at" => job[:run_at],
|
23
|
+
"queue" => job[:queue],
|
24
|
+
"wrapped" => job[:wrapped],
|
25
|
+
"created_at" => job[:created_at].to_f,
|
26
|
+
}.tap(&:compact!)
|
27
|
+
end
|
26
28
|
|
27
|
-
|
29
|
+
instrumenter.instrument("enqueue_batch.publisher") do |notification|
|
30
|
+
enqueue_batch(batch, items, notification)
|
31
|
+
end
|
32
|
+
end
|
28
33
|
end
|
29
34
|
purge_expired_published_jobs
|
30
35
|
rescue StandardError => ex
|
@@ -33,16 +38,16 @@ module SidekiqPublisher
|
|
33
38
|
|
34
39
|
private
|
35
40
|
|
36
|
-
attr_reader :client, :job_class_cache
|
41
|
+
attr_reader :client, :job_class_cache, :instrumenter
|
37
42
|
|
38
|
-
def
|
43
|
+
def enqueue_batch(batch, items, notification)
|
39
44
|
pushed_count = client.bulk_push(items)
|
40
45
|
published_count = update_jobs_as_published!(batch)
|
41
46
|
rescue StandardError => ex
|
42
47
|
failure_warning(__method__, ex)
|
43
48
|
ensure
|
44
49
|
published_count = update_jobs_as_published!(batch) if pushed_count.present? && published_count.nil?
|
45
|
-
|
50
|
+
notification[:published_count] = published_count if published_count.present?
|
46
51
|
end
|
47
52
|
|
48
53
|
def lookup_job_class(name)
|
@@ -56,7 +61,7 @@ module SidekiqPublisher
|
|
56
61
|
end
|
57
62
|
|
58
63
|
def purge_expired_published_jobs
|
59
|
-
Job.purge_expired_published! if perform_purge?
|
64
|
+
Job.purge_expired_published!(instrumenter: instrumenter) if perform_purge?
|
60
65
|
end
|
61
66
|
|
62
67
|
def perform_purge?
|
@@ -64,17 +69,13 @@ module SidekiqPublisher
|
|
64
69
|
end
|
65
70
|
|
66
71
|
def failure_warning(method, ex)
|
67
|
-
logger.warn("#{self.class.name}: msg=\"#{method} failed\" error=#{ex.class} error_msg=#{ex.message.inspect}\n"
|
68
|
-
|
69
|
-
|
72
|
+
logger.warn("#{self.class.name}: msg=\"#{method} failed\" error=#{ex.class} error_msg=#{ex.message.inspect}\n")
|
73
|
+
instrumenter.instrument("error.publisher",
|
74
|
+
exception_object: ex, exception: [ex.class.name, ex.message])
|
70
75
|
end
|
71
76
|
|
72
77
|
def logger
|
73
78
|
SidekiqPublisher.logger
|
74
79
|
end
|
75
|
-
|
76
|
-
def metrics_reporter
|
77
|
-
SidekiqPublisher.metrics_reporter
|
78
|
-
end
|
79
80
|
end
|
80
81
|
end
|
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
module SidekiqPublisher
|
4
4
|
module ReportUnpublishedCount
|
5
|
-
def self.call
|
6
|
-
|
7
|
-
|
8
|
-
SidekiqPublisher::Job.unpublished.count)
|
5
|
+
def self.call(instrumenter: Instrumenter.new)
|
6
|
+
instrumenter.instrument("unpublished.reporter",
|
7
|
+
unpublished_count: SidekiqPublisher::Job.unpublished.count)
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
@@ -7,12 +7,13 @@ module SidekiqPublisher
|
|
7
7
|
LISTENER_TIMEOUT_SECONDS = 60
|
8
8
|
CHANNEL_NAME = "sidekiq_publisher_job"
|
9
9
|
|
10
|
-
def self.run
|
11
|
-
new.run
|
10
|
+
def self.run(instrumenter = Instrumenter.new)
|
11
|
+
new(instrumenter).run
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize
|
15
|
-
@
|
14
|
+
def initialize(instrumenter = Instrumenter.new)
|
15
|
+
@instrumenter = instrumenter
|
16
|
+
@publisher = Publisher.new(instrumenter: @instrumenter)
|
16
17
|
end
|
17
18
|
|
18
19
|
def run
|
@@ -20,24 +21,32 @@ module SidekiqPublisher
|
|
20
21
|
CHANNEL_NAME,
|
21
22
|
listen_timeout: LISTENER_TIMEOUT_SECONDS
|
22
23
|
) do |listener|
|
23
|
-
listener.on_start {
|
24
|
-
listener.on_notify {
|
24
|
+
listener.on_start { call_publish("start") }
|
25
|
+
listener.on_notify { call_publish("notify") }
|
25
26
|
listener.on_timeout { listener_timeout }
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
30
|
private
|
30
31
|
|
31
|
-
attr_reader :publisher
|
32
|
+
attr_reader :publisher, :instrumenter
|
32
33
|
|
33
|
-
def
|
34
|
-
|
35
|
-
SidekiqPublisher.logger&.warn(
|
36
|
-
"#{self.class.name}: msg='publishing pending jobs at timeout'"
|
37
|
-
)
|
34
|
+
def call_publish(event)
|
35
|
+
instrumenter.instrument("#{event}.publisher") do
|
38
36
|
publisher.publish
|
39
|
-
|
40
|
-
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def listener_timeout
|
41
|
+
instrumenter.instrument("timeout.listener") do
|
42
|
+
if Job.unpublished.exists?
|
43
|
+
SidekiqPublisher.logger&.warn(
|
44
|
+
"#{self.class.name}: msg='publishing pending jobs at timeout'"
|
45
|
+
)
|
46
|
+
call_publish("timeout")
|
47
|
+
else
|
48
|
+
Job.purge_expired_published!(instrumenter: instrumenter)
|
49
|
+
end
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
data/sidekiq_publisher.gemspec
CHANGED
@@ -45,6 +45,7 @@ Gem::Specification.new do |spec|
|
|
45
45
|
spec.add_development_dependency "appraisal"
|
46
46
|
spec.add_development_dependency "bundler", "~> 1.12"
|
47
47
|
spec.add_development_dependency "database_cleaner"
|
48
|
+
spec.add_development_dependency "ddtrace", ">= 0.39.0"
|
48
49
|
spec.add_development_dependency "ezcater_matchers"
|
49
50
|
spec.add_development_dependency "ezcater_rubocop", "1.0.2"
|
50
51
|
spec.add_development_dependency "factory_bot"
|
@@ -54,9 +55,9 @@ Gem::Specification.new do |spec|
|
|
54
55
|
spec.add_development_dependency "rspec", "~> 3.4"
|
55
56
|
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
|
56
57
|
spec.add_development_dependency "shoulda-matchers"
|
57
|
-
spec.add_development_dependency "simplecov"
|
58
|
+
spec.add_development_dependency "simplecov", "< 0.18"
|
58
59
|
|
59
60
|
spec.add_runtime_dependency "activerecord-postgres_pub_sub", ">= 0.4.0"
|
60
61
|
spec.add_runtime_dependency "activesupport", ">= 5.1", "< 6.1"
|
61
|
-
spec.add_runtime_dependency "sidekiq", ">= 5.0.4", "<
|
62
|
+
spec.add_runtime_dependency "sidekiq", ">= 5.0.4", "< 7.0"
|
62
63
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ddtrace
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.39.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.39.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: ezcater_matchers
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,16 +210,16 @@ dependencies:
|
|
196
210
|
name: simplecov
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
|
-
- - "
|
213
|
+
- - "<"
|
200
214
|
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
215
|
+
version: '0.18'
|
202
216
|
type: :development
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
|
-
- - "
|
220
|
+
- - "<"
|
207
221
|
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
222
|
+
version: '0.18'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: activerecord-postgres_pub_sub
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,7 +263,7 @@ dependencies:
|
|
249
263
|
version: 5.0.4
|
250
264
|
- - "<"
|
251
265
|
- !ruby/object:Gem::Version
|
252
|
-
version: '
|
266
|
+
version: '7.0'
|
253
267
|
type: :runtime
|
254
268
|
prerelease: false
|
255
269
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -259,7 +273,7 @@ dependencies:
|
|
259
273
|
version: 5.0.4
|
260
274
|
- - "<"
|
261
275
|
- !ruby/object:Gem::Version
|
262
|
-
version: '
|
276
|
+
version: '7.0'
|
263
277
|
description: Publisher for enqueuing jobs to Sidekiq
|
264
278
|
email:
|
265
279
|
- engineering@ezcater.com
|
@@ -268,25 +282,34 @@ extensions: []
|
|
268
282
|
extra_rdoc_files: []
|
269
283
|
files:
|
270
284
|
- ".codeclimate.yml"
|
285
|
+
- ".github/CODEOWNERS"
|
271
286
|
- Appraisals
|
272
287
|
- CHANGELOG.md
|
288
|
+
- Dockerfile
|
273
289
|
- Gemfile
|
274
290
|
- LICENSE.txt
|
275
291
|
- README.md
|
292
|
+
- docker-compose.yml
|
276
293
|
- gemfiles/rails_5.1.gemfile
|
277
294
|
- gemfiles/rails_5.2.gemfile
|
278
295
|
- gemfiles/rails_5.2_sidekiq_5.0.gemfile
|
279
296
|
- gemfiles/rails_5.2_sidekiq_5.1.gemfile
|
280
297
|
- gemfiles/rails_5.2_sidekiq_5.2.gemfile
|
281
298
|
- gemfiles/rails_5.2_sidekiq_6.0.gemfile
|
299
|
+
- gemfiles/rails_5.2_sidekiq_6.1.gemfile
|
282
300
|
- gemfiles/rails_6.0_sidekiq_5.2.gemfile
|
283
301
|
- gemfiles/rails_6.0_sidekiq_6.0.gemfile
|
302
|
+
- gemfiles/rails_6.0_sidekiq_6.1.gemfile
|
284
303
|
- lib/active_job/queue_adapters/sidekiq_publisher_adapter.rb
|
285
304
|
- lib/generators/sidekiq_publisher/install_generator.rb
|
286
305
|
- lib/generators/sidekiq_publisher/templates/create_sidekiq_publisher_jobs.rb
|
287
306
|
- lib/sidekiq_publisher.rb
|
288
307
|
- lib/sidekiq_publisher/client.rb
|
308
|
+
- lib/sidekiq_publisher/datadog_apm.rb
|
309
|
+
- lib/sidekiq_publisher/exception_reporter.rb
|
310
|
+
- lib/sidekiq_publisher/instrumenter.rb
|
289
311
|
- lib/sidekiq_publisher/job.rb
|
312
|
+
- lib/sidekiq_publisher/metrics_reporter.rb
|
290
313
|
- lib/sidekiq_publisher/publisher.rb
|
291
314
|
- lib/sidekiq_publisher/railtie.rb
|
292
315
|
- lib/sidekiq_publisher/report_unpublished_count.rb
|
@@ -302,7 +325,7 @@ licenses:
|
|
302
325
|
- MIT
|
303
326
|
metadata:
|
304
327
|
allowed_push_host: https://rubygems.org
|
305
|
-
post_install_message:
|
328
|
+
post_install_message:
|
306
329
|
rdoc_options: []
|
307
330
|
require_paths:
|
308
331
|
- lib
|
@@ -317,8 +340,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
340
|
- !ruby/object:Gem::Version
|
318
341
|
version: '0'
|
319
342
|
requirements: []
|
320
|
-
rubygems_version: 3.
|
321
|
-
signing_key:
|
343
|
+
rubygems_version: 3.1.4
|
344
|
+
signing_key:
|
322
345
|
specification_version: 4
|
323
346
|
summary: Publisher for enqueuing jobs to Sidekiq
|
324
347
|
test_files: []
|