rails_band 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/rails_band/active_job/event/discard.rb +22 -0
- data/lib/rails_band/active_job/event/enqueue.rb +18 -0
- data/lib/rails_band/active_job/event/enqueue_at.rb +18 -0
- data/lib/rails_band/active_job/event/enqueue_retry.rb +26 -0
- data/lib/rails_band/active_job/event/perform.rb +18 -0
- data/lib/rails_band/active_job/event/perform_start.rb +18 -0
- data/lib/rails_band/active_job/event/retry_stopped.rb +22 -0
- data/lib/rails_band/active_job/log_subscriber.rb +52 -0
- data/lib/rails_band/railtie.rb +11 -0
- data/lib/rails_band/version.rb +1 -1
- data/lib/rails_band.rb +4 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2068455c0eab607cbdc32392362c6a181b0789d8bd41e77201c7bb06e3eb8ba8
|
4
|
+
data.tar.gz: c27bcf5e8dcd06c7f87f164ca1a7f58e537b5910bba7b0a98a7ea3a003649fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936e787242f04a6d7d81bf29993d87bba1187cf27d3e706cb0de672dd27100e99ab029da802871bd044ad722801a4fa6f4f6f22b33e3f1c160935dce10c9b369
|
7
|
+
data.tar.gz: 549f64623c4374c3067d0e82a853eace86c14873a89c5e894118ca8e4c1122377d89d55c10c7816b86db391d0130df423c68db25d9d898e4de769947554c1e54
|
data/README.md
CHANGED
@@ -116,13 +116,13 @@ These are Rails Instrumentation API hooks supported by this gem so far.
|
|
116
116
|
|
117
117
|
| Event name | Supported |
|
118
118
|
| ------------------------------------------------------------------------------------------------------------------------- | --------- |
|
119
|
-
| [`enqueue_at.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-at-active-job) |
|
120
|
-
| [`enqueue.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job) |
|
121
|
-
| [`enqueue_retry.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-retry-active-job) |
|
122
|
-
| [`perform_start.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job) |
|
123
|
-
| [`perform.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job) |
|
124
|
-
| [`retry_stopped.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#retry-stopped-active-job) |
|
125
|
-
| [`discard.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#discard-active-job) |
|
119
|
+
| [`enqueue_at.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-at-active-job) | ✅ |
|
120
|
+
| [`enqueue.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-active-job) | ✅ |
|
121
|
+
| [`enqueue_retry.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#enqueue-retry-active-job) | ✅ |
|
122
|
+
| [`perform_start.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job) | ✅ |
|
123
|
+
| [`perform.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job) | ✅ |
|
124
|
+
| [`retry_stopped.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#retry-stopped-active-job) | ✅ |
|
125
|
+
| [`discard.active_job`](https://guides.rubyonrails.org/active_support_instrumentation.html#discard-active-job) | ✅ |
|
126
126
|
|
127
127
|
### Action Cable
|
128
128
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `discard.active_job`.
|
7
|
+
class Discard < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
|
16
|
+
def error
|
17
|
+
@error ||= @event.payload.fetch(:error)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `enqueue.active_job`.
|
7
|
+
class Enqueue < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `enqueue_at.active_job`.
|
7
|
+
class EnqueueAt < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `enqueue_retry.active_job`.
|
7
|
+
class EnqueueRetry < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
|
16
|
+
def wait
|
17
|
+
@wait ||= @event.payload.fetch(:wait)
|
18
|
+
end
|
19
|
+
|
20
|
+
def error
|
21
|
+
@error ||= @event.payload.fetch(:error)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `perform.active_job`.
|
7
|
+
class Perform < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `perform_start.active_job`.
|
7
|
+
class PerformStart < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveJob
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `retry_stopped.active_job`.
|
7
|
+
class RetryStopped < BaseEvent
|
8
|
+
def adapter
|
9
|
+
@adapter ||= @event.payload.fetch(:adapter)
|
10
|
+
end
|
11
|
+
|
12
|
+
def job
|
13
|
+
@job ||= @event.payload.fetch(:job)
|
14
|
+
end
|
15
|
+
|
16
|
+
def error
|
17
|
+
@error ||= @event.payload.fetch(:error)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_band/active_job/event/enqueue_at'
|
4
|
+
require 'rails_band/active_job/event/enqueue'
|
5
|
+
require 'rails_band/active_job/event/enqueue_retry'
|
6
|
+
require 'rails_band/active_job/event/perform_start'
|
7
|
+
require 'rails_band/active_job/event/perform'
|
8
|
+
require 'rails_band/active_job/event/retry_stopped'
|
9
|
+
require 'rails_band/active_job/event/discard'
|
10
|
+
|
11
|
+
module RailsBand
|
12
|
+
module ActiveJob
|
13
|
+
# The custom LogSubscriber for ActiveJob.
|
14
|
+
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
15
|
+
mattr_accessor :consumers
|
16
|
+
|
17
|
+
def enqueue_at(event)
|
18
|
+
consumer_of(__method__)&.call(Event::EnqueueAt.new(event))
|
19
|
+
end
|
20
|
+
|
21
|
+
def enqueue(event)
|
22
|
+
consumer_of(__method__)&.call(Event::Enqueue.new(event))
|
23
|
+
end
|
24
|
+
|
25
|
+
def enqueue_retry(event)
|
26
|
+
consumer_of(__method__)&.call(Event::EnqueueRetry.new(event))
|
27
|
+
end
|
28
|
+
|
29
|
+
def perform_start(event)
|
30
|
+
consumer_of(__method__)&.call(Event::PerformStart.new(event))
|
31
|
+
end
|
32
|
+
|
33
|
+
def perform(event)
|
34
|
+
consumer_of(__method__)&.call(Event::Perform.new(event))
|
35
|
+
end
|
36
|
+
|
37
|
+
def retry_stopped(event)
|
38
|
+
consumer_of(__method__)&.call(Event::RetryStopped.new(event))
|
39
|
+
end
|
40
|
+
|
41
|
+
def discard(event)
|
42
|
+
consumer_of(__method__)&.call(Event::Discard.new(event))
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def consumer_of(sub_event)
|
48
|
+
consumers[:"#{sub_event}.active_job"] || consumers[:active_job] || consumers[:default]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/rails_band/railtie.rb
CHANGED
@@ -31,6 +31,17 @@ module RailsBand
|
|
31
31
|
end
|
32
32
|
|
33
33
|
RailsBand::ActiveSupport::LogSubscriber.attach_to :active_support
|
34
|
+
|
35
|
+
if defined?(::ActiveJob)
|
36
|
+
require 'active_job/logging'
|
37
|
+
|
38
|
+
if defined?(::ActiveJob::Logging::LogSubscriber)
|
39
|
+
swap.call(::ActiveJob::Logging::LogSubscriber, RailsBand::ActiveJob::LogSubscriber, :active_job)
|
40
|
+
else
|
41
|
+
require 'active_job/log_subscriber'
|
42
|
+
swap.call(::ActiveJob::LogSubscriber, RailsBand::ActiveJob::LogSubscriber, :active_job)
|
43
|
+
end
|
44
|
+
end
|
34
45
|
end
|
35
46
|
end
|
36
47
|
end
|
data/lib/rails_band/version.rb
CHANGED
data/lib/rails_band.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_band
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yutaka Kamei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -55,6 +55,14 @@ files:
|
|
55
55
|
- lib/rails_band/action_view/event/render_template.rb
|
56
56
|
- lib/rails_band/action_view/from_views.rb
|
57
57
|
- lib/rails_band/action_view/log_subscriber.rb
|
58
|
+
- lib/rails_band/active_job/event/discard.rb
|
59
|
+
- lib/rails_band/active_job/event/enqueue.rb
|
60
|
+
- lib/rails_band/active_job/event/enqueue_at.rb
|
61
|
+
- lib/rails_band/active_job/event/enqueue_retry.rb
|
62
|
+
- lib/rails_band/active_job/event/perform.rb
|
63
|
+
- lib/rails_band/active_job/event/perform_start.rb
|
64
|
+
- lib/rails_band/active_job/event/retry_stopped.rb
|
65
|
+
- lib/rails_band/active_job/log_subscriber.rb
|
58
66
|
- lib/rails_band/active_record/event/instantiation.rb
|
59
67
|
- lib/rails_band/active_record/event/sql.rb
|
60
68
|
- lib/rails_band/active_record/event/strict_loading_violation.rb
|