rails_band 0.4.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -17
- data/lib/rails_band/action_cable/event/broadcast.rb +22 -0
- data/lib/rails_band/action_cable/event/perform_action.rb +22 -0
- data/lib/rails_band/action_cable/event/transmit.rb +22 -0
- data/lib/rails_band/action_cable/event/transmit_subscription_confirmation.rb +14 -0
- data/lib/rails_band/action_cable/event/transmit_subscription_rejection.rb +14 -0
- data/lib/rails_band/action_cable/log_subscriber.rb +42 -0
- data/lib/rails_band/active_storage/event/analyze.rb +14 -0
- data/lib/rails_band/active_storage/event/preview.rb +16 -0
- data/lib/rails_band/active_storage/event/service_delete.rb +20 -0
- data/lib/rails_band/active_storage/event/service_delete_prefixed.rb +18 -0
- data/lib/rails_band/active_storage/event/service_download.rb +20 -0
- data/lib/rails_band/active_storage/event/service_download_chunk.rb +24 -0
- data/lib/rails_band/active_storage/event/service_exist.rb +26 -0
- data/lib/rails_band/active_storage/event/service_streaming_download.rb +20 -0
- data/lib/rails_band/active_storage/event/service_update_metadata.rb +28 -0
- data/lib/rails_band/active_storage/event/service_upload.rb +26 -0
- data/lib/rails_band/active_storage/event/service_url.rb +24 -0
- data/lib/rails_band/active_storage/event/transform.rb +11 -0
- data/lib/rails_band/active_storage/log_subscriber.rb +77 -0
- data/lib/rails_band/railtie.rb +11 -0
- data/lib/rails_band/version.rb +1 -1
- data/lib/rails_band.rb +8 -0
- metadata +29 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33531dca2bfc581e2d892bfa6962bb31d41e1fef075917a8cb4427ed6b65c2e5
|
4
|
+
data.tar.gz: a4f5af5171bf836e9071cddffe9b06654eba3538c58b0bf7c5bbde93587e0686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3c5c8628d6e8a0bb963e257d6eaa1c2cd8278b71f477034d33ea715c2563efe8854b466daa3aa9dadce94da15840ca2f4e65ee49fdfb0a30fa9880d20365ed
|
7
|
+
data.tar.gz: bc5f016c6b62c01b5081a9bc75a882edbcb51e7be37b65fa24ba17ef570855de37e6fdce6c86a1cccbb8d78aa77b2e5f47e077e086e8f138513fd87230e34a1f
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# rails_band
|
2
2
|
|
3
3
|
<a href="https://github.com/yykamei/rails_band/actions/workflows/ci.yml"><img alt="GitHub Actions workflow status" src="https://github.com/yykamei/rails_band/actions/workflows/ci.yml/badge.svg"></a>
|
4
|
-
<a href="https://rubygems.org/gems/rails_band"><img alt="
|
4
|
+
<a href="https://rubygems.org/gems/rails_band"><img alt="rails_band" src="https://img.shields.io/gem/v/rails_band"></a>
|
5
5
|
|
6
6
|
Easy-to-use Rails Instrumentation API.
|
7
7
|
|
@@ -82,6 +82,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
|
|
82
82
|
| [`render_template.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-template-action-view) | ✅ |
|
83
83
|
| [`render_partial.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-partial-action-view) | ✅ |
|
84
84
|
| [`render_collection.action_view`](https://guides.rubyonrails.org/active_support_instrumentation.html#render-collection-action-view) | ✅ |
|
85
|
+
| [`render_layout.action_view`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#render-layout-action-view) | |
|
85
86
|
|
86
87
|
### Active Record
|
87
88
|
|
@@ -128,27 +129,28 @@ These are Rails Instrumentation API hooks supported by this gem so far.
|
|
128
129
|
|
129
130
|
| Event name | Supported |
|
130
131
|
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
|
131
|
-
| [`perform_action.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-action-action-cable) |
|
132
|
-
| [`transmit.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-action-cable) |
|
133
|
-
| [`transmit_subscription_confirmation.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-confirmation-action-cable) |
|
134
|
-
| [`transmit_subscription_rejection.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-rejection-action-cable) |
|
135
|
-
| [`broadcast.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#broadcast-action-cable) |
|
132
|
+
| [`perform_action.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#perform-action-action-cable) | ✅ |
|
133
|
+
| [`transmit.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-action-cable) | ✅ |
|
134
|
+
| [`transmit_subscription_confirmation.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-confirmation-action-cable) | ✅ |
|
135
|
+
| [`transmit_subscription_rejection.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#transmit-subscription-rejection-action-cable) | ✅ |
|
136
|
+
| [`broadcast.action_cable`](https://guides.rubyonrails.org/active_support_instrumentation.html#broadcast-action-cable) | ✅ |
|
136
137
|
|
137
138
|
### Active Storage
|
138
139
|
|
139
140
|
| Event name | Supported |
|
140
141
|
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
|
141
|
-
| [`service_upload.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-upload-active-storage) |
|
142
|
-
| [`service_streaming_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-streaming-download-active-storage) |
|
143
|
-
| [`service_download_chunk.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-chunk-active-storage) |
|
144
|
-
| [`service_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-active-storage) |
|
145
|
-
| [`service_delete.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-active-storage) |
|
146
|
-
| [`service_delete_prefixed.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-prefixed-active-storage) |
|
147
|
-
| [`service_exist.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-exist-active-storage) |
|
148
|
-
| [`service_url.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-url-active-storage) |
|
149
|
-
| [`service_update_metadata.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-update-metadata-active-storage) |
|
150
|
-
| [`preview.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#preview-active-storage) |
|
151
|
-
| [`
|
142
|
+
| [`service_upload.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-upload-active-storage) | ✅ |
|
143
|
+
| [`service_streaming_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-streaming-download-active-storage) | ✅ |
|
144
|
+
| [`service_download_chunk.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-chunk-active-storage) | ✅ |
|
145
|
+
| [`service_download.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-download-active-storage) | ✅ |
|
146
|
+
| [`service_delete.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-active-storage) | ✅ |
|
147
|
+
| [`service_delete_prefixed.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-delete-prefixed-active-storage) | ✅ |
|
148
|
+
| [`service_exist.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-exist-active-storage) | ✅ |
|
149
|
+
| [`service_url.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-url-active-storage) | ✅ |
|
150
|
+
| [`service_update_metadata.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#service-update-metadata-active-storage) | ✅ |
|
151
|
+
| [`preview.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#preview-active-storage) | ✅ |
|
152
|
+
| [`transform.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#transform-active-storage) | ✅ |
|
153
|
+
| [`analyze.active_storage`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#analyze-active-storage) | ✅ |
|
152
154
|
|
153
155
|
### Railties
|
154
156
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `broadcast.action_cable`.
|
7
|
+
class Broadcast < BaseEvent
|
8
|
+
def broadcasting
|
9
|
+
@broadcasting ||= @event.payload.fetch(:broadcasting)
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
@message ||= @event.payload.fetch(:message)
|
14
|
+
end
|
15
|
+
|
16
|
+
def coder
|
17
|
+
@coder ||= @event.payload.fetch(:coder)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `perform_action.action_cable`.
|
7
|
+
class PerformAction < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
|
12
|
+
def action
|
13
|
+
@action ||= @event.payload.fetch(:action)
|
14
|
+
end
|
15
|
+
|
16
|
+
def data
|
17
|
+
@data ||= @event.payload.fetch(:data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `transmit.action_cable`.
|
7
|
+
class Transmit < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
|
12
|
+
def data
|
13
|
+
@data ||= @event.payload.fetch(:data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def via
|
17
|
+
@via ||= @event.payload.fetch(:via)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `transmit_subscription_confirmation.action_cable`.
|
7
|
+
class TransmitSubscriptionConfirmation < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActionCable
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `transmit_subscription_rejection.action_cable`.
|
7
|
+
class TransmitSubscriptionRejection < BaseEvent
|
8
|
+
def channel_class
|
9
|
+
@channel_class ||= @event.payload.fetch(:channel_class)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_band/action_cable/event/perform_action'
|
4
|
+
require 'rails_band/action_cable/event/transmit'
|
5
|
+
require 'rails_band/action_cable/event/transmit_subscription_confirmation'
|
6
|
+
require 'rails_band/action_cable/event/transmit_subscription_rejection'
|
7
|
+
require 'rails_band/action_cable/event/broadcast'
|
8
|
+
|
9
|
+
module RailsBand
|
10
|
+
module ActionCable
|
11
|
+
# The custom LogSubscriber for ActionCable.
|
12
|
+
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
13
|
+
mattr_accessor :consumers
|
14
|
+
|
15
|
+
def perform_action(event)
|
16
|
+
consumer_of(__method__)&.call(Event::PerformAction.new(event))
|
17
|
+
end
|
18
|
+
|
19
|
+
def transmit(event)
|
20
|
+
consumer_of(__method__)&.call(Event::Transmit.new(event))
|
21
|
+
end
|
22
|
+
|
23
|
+
def transmit_subscription_confirmation(event)
|
24
|
+
consumer_of(__method__)&.call(Event::TransmitSubscriptionConfirmation.new(event))
|
25
|
+
end
|
26
|
+
|
27
|
+
def transmit_subscription_rejection(event)
|
28
|
+
consumer_of(__method__)&.call(Event::TransmitSubscriptionRejection.new(event))
|
29
|
+
end
|
30
|
+
|
31
|
+
def broadcast(event)
|
32
|
+
consumer_of(__method__)&.call(Event::Broadcast.new(event))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def consumer_of(sub_event)
|
38
|
+
consumers[:"#{sub_event}.action_cable"] || consumers[:action_cable] || consumers[:default]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `analyze.active_storage`.
|
7
|
+
class Analyze < BaseEvent
|
8
|
+
def analyzer
|
9
|
+
@analyzer ||= @event.payload.fetch(:analyzer)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `preview.active_storage`.
|
7
|
+
class Preview < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_delete.active_storage`.
|
7
|
+
class ServiceDelete < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_delete_prefixed.active_storage`.
|
7
|
+
class ServiceDeletePrefixed < BaseEvent
|
8
|
+
def prefix
|
9
|
+
@prefix ||= @event.payload.fetch(:prefix)
|
10
|
+
end
|
11
|
+
|
12
|
+
def service
|
13
|
+
@service ||= @event.payload.fetch(:service)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_download.active_storage`.
|
7
|
+
class ServiceDownload < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_download_chunk.active_storage`.
|
7
|
+
class ServiceDownloadChunk < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def range
|
19
|
+
@range ||= @event.payload.fetch(:range)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_exist.active_storage`.
|
7
|
+
class ServiceExist < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def exist
|
19
|
+
return @exist if defined? @exist
|
20
|
+
|
21
|
+
@exist = @event.payload.fetch(:exist)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_streaming_download.active_storage`.
|
7
|
+
class ServiceStreamingDownload < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_update_metadata.active_storage`.
|
7
|
+
class ServiceUpdateMetadata < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def content_type
|
19
|
+
@content_type ||= @event.payload.fetch(:content_type)
|
20
|
+
end
|
21
|
+
|
22
|
+
def disposition
|
23
|
+
@disposition ||= @event.payload.fetch(:disposition)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_upload.active_storage`.
|
7
|
+
class ServiceUpload < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def checksum
|
15
|
+
return @checksum if defined? @checksum
|
16
|
+
|
17
|
+
@checksum = @event.payload[:checksum]
|
18
|
+
end
|
19
|
+
|
20
|
+
def service
|
21
|
+
@service ||= @event.payload.fetch(:service)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsBand
|
4
|
+
module ActiveStorage
|
5
|
+
module Event
|
6
|
+
# A wrapper for the event that is passed to `service_url.active_storage`.
|
7
|
+
class ServiceUrl < BaseEvent
|
8
|
+
def key
|
9
|
+
return @key if defined? @key
|
10
|
+
|
11
|
+
@key = @event.payload[:key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def service
|
15
|
+
@service ||= @event.payload.fetch(:service)
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
@url ||= @event.payload.fetch(:url)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_band/active_storage/event/service_upload'
|
4
|
+
require 'rails_band/active_storage/event/service_streaming_download'
|
5
|
+
require 'rails_band/active_storage/event/service_download_chunk'
|
6
|
+
require 'rails_band/active_storage/event/service_download'
|
7
|
+
require 'rails_band/active_storage/event/service_delete'
|
8
|
+
require 'rails_band/active_storage/event/service_delete_prefixed'
|
9
|
+
require 'rails_band/active_storage/event/service_exist'
|
10
|
+
require 'rails_band/active_storage/event/service_url'
|
11
|
+
require 'rails_band/active_storage/event/service_update_metadata'
|
12
|
+
require 'rails_band/active_storage/event/preview'
|
13
|
+
require 'rails_band/active_storage/event/transform'
|
14
|
+
require 'rails_band/active_storage/event/analyze'
|
15
|
+
|
16
|
+
module RailsBand
|
17
|
+
module ActiveStorage
|
18
|
+
# The custom LogSubscriber for ActiveStorage.
|
19
|
+
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
20
|
+
mattr_accessor :consumers
|
21
|
+
|
22
|
+
def service_upload(event)
|
23
|
+
consumer_of(__method__)&.call(Event::ServiceUpload.new(event))
|
24
|
+
end
|
25
|
+
|
26
|
+
def service_streaming_download(event)
|
27
|
+
consumer_of(__method__)&.call(Event::ServiceStreamingDownload.new(event))
|
28
|
+
end
|
29
|
+
|
30
|
+
def service_download_chunk(event)
|
31
|
+
consumer_of(__method__)&.call(Event::ServiceDownloadChunk.new(event))
|
32
|
+
end
|
33
|
+
|
34
|
+
def service_download(event)
|
35
|
+
consumer_of(__method__)&.call(Event::ServiceDownload.new(event))
|
36
|
+
end
|
37
|
+
|
38
|
+
def service_delete(event)
|
39
|
+
consumer_of(__method__)&.call(Event::ServiceDelete.new(event))
|
40
|
+
end
|
41
|
+
|
42
|
+
def service_delete_prefixed(event)
|
43
|
+
consumer_of(__method__)&.call(Event::ServiceDeletePrefixed.new(event))
|
44
|
+
end
|
45
|
+
|
46
|
+
def service_exist(event)
|
47
|
+
consumer_of(__method__)&.call(Event::ServiceExist.new(event))
|
48
|
+
end
|
49
|
+
|
50
|
+
def service_url(event)
|
51
|
+
consumer_of(__method__)&.call(Event::ServiceUrl.new(event))
|
52
|
+
end
|
53
|
+
|
54
|
+
def service_update_metadata(event)
|
55
|
+
consumer_of(__method__)&.call(Event::ServiceUpdateMetadata.new(event))
|
56
|
+
end
|
57
|
+
|
58
|
+
def preview(event)
|
59
|
+
consumer_of(__method__)&.call(Event::Preview.new(event))
|
60
|
+
end
|
61
|
+
|
62
|
+
def transform(event)
|
63
|
+
consumer_of(__method__)&.call(Event::Transform.new(event))
|
64
|
+
end
|
65
|
+
|
66
|
+
def analyze(event)
|
67
|
+
consumer_of(__method__)&.call(Event::Analyze.new(event))
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def consumer_of(sub_event)
|
73
|
+
consumers[:"#{sub_event}.active_storage"] || consumers[:active_storage] || consumers[:default]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/rails_band/railtie.rb
CHANGED
@@ -30,6 +30,17 @@ module RailsBand
|
|
30
30
|
swap.call(::ActionMailer::LogSubscriber, RailsBand::ActionMailer::LogSubscriber, :action_mailer)
|
31
31
|
end
|
32
32
|
|
33
|
+
if defined?(::ActionCable)
|
34
|
+
RailsBand::ActionCable::LogSubscriber.consumers = consumers
|
35
|
+
RailsBand::ActionCable::LogSubscriber.attach_to :action_cable
|
36
|
+
end
|
37
|
+
|
38
|
+
if defined?(::ActiveStorage)
|
39
|
+
RailsBand::ActiveStorage::LogSubscriber.consumers = consumers
|
40
|
+
RailsBand::ActiveStorage::LogSubscriber.attach_to :active_storage
|
41
|
+
end
|
42
|
+
|
43
|
+
RailsBand::ActiveSupport::LogSubscriber.consumers = consumers
|
33
44
|
RailsBand::ActiveSupport::LogSubscriber.attach_to :active_support
|
34
45
|
|
35
46
|
if defined?(::ActiveJob)
|
data/lib/rails_band/version.rb
CHANGED
data/lib/rails_band.rb
CHANGED
@@ -31,4 +31,12 @@ module RailsBand
|
|
31
31
|
module ActiveJob
|
32
32
|
autoload :LogSubscriber, 'rails_band/active_job/log_subscriber'
|
33
33
|
end
|
34
|
+
|
35
|
+
module ActionCable
|
36
|
+
autoload :LogSubscriber, 'rails_band/action_cable/log_subscriber'
|
37
|
+
end
|
38
|
+
|
39
|
+
module ActiveStorage
|
40
|
+
autoload :LogSubscriber, 'rails_band/active_storage/log_subscriber'
|
41
|
+
end
|
34
42
|
end
|
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.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yutaka Kamei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6.0'
|
20
|
+
- - "!="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '6.0'
|
30
|
+
- - "!="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 7.0.0
|
27
33
|
description: A Rails plugin to facilitate the use of Rails Instrumentation API.
|
28
34
|
email:
|
29
35
|
- kamei@yykamei.me
|
@@ -35,6 +41,12 @@ files:
|
|
35
41
|
- README.md
|
36
42
|
- Rakefile
|
37
43
|
- lib/rails_band.rb
|
44
|
+
- lib/rails_band/action_cable/event/broadcast.rb
|
45
|
+
- lib/rails_band/action_cable/event/perform_action.rb
|
46
|
+
- lib/rails_band/action_cable/event/transmit.rb
|
47
|
+
- lib/rails_band/action_cable/event/transmit_subscription_confirmation.rb
|
48
|
+
- lib/rails_band/action_cable/event/transmit_subscription_rejection.rb
|
49
|
+
- lib/rails_band/action_cable/log_subscriber.rb
|
38
50
|
- lib/rails_band/action_controller/event/exist_fragment.rb
|
39
51
|
- lib/rails_band/action_controller/event/expire_fragment.rb
|
40
52
|
- lib/rails_band/action_controller/event/halted_callback.rb
|
@@ -67,6 +79,19 @@ files:
|
|
67
79
|
- lib/rails_band/active_record/event/sql.rb
|
68
80
|
- lib/rails_band/active_record/event/strict_loading_violation.rb
|
69
81
|
- lib/rails_band/active_record/log_subscriber.rb
|
82
|
+
- lib/rails_band/active_storage/event/analyze.rb
|
83
|
+
- lib/rails_band/active_storage/event/preview.rb
|
84
|
+
- lib/rails_band/active_storage/event/service_delete.rb
|
85
|
+
- lib/rails_band/active_storage/event/service_delete_prefixed.rb
|
86
|
+
- lib/rails_band/active_storage/event/service_download.rb
|
87
|
+
- lib/rails_band/active_storage/event/service_download_chunk.rb
|
88
|
+
- lib/rails_band/active_storage/event/service_exist.rb
|
89
|
+
- lib/rails_band/active_storage/event/service_streaming_download.rb
|
90
|
+
- lib/rails_band/active_storage/event/service_update_metadata.rb
|
91
|
+
- lib/rails_band/active_storage/event/service_upload.rb
|
92
|
+
- lib/rails_band/active_storage/event/service_url.rb
|
93
|
+
- lib/rails_band/active_storage/event/transform.rb
|
94
|
+
- lib/rails_band/active_storage/log_subscriber.rb
|
70
95
|
- lib/rails_band/active_support/event/cache_delete.rb
|
71
96
|
- lib/rails_band/active_support/event/cache_delete_multi.rb
|
72
97
|
- lib/rails_band/active_support/event/cache_exist.rb
|
@@ -88,6 +113,7 @@ metadata:
|
|
88
113
|
homepage_uri: https://github.com/yykamei/rails_band
|
89
114
|
source_code_uri: https://github.com/yykamei/rails_band
|
90
115
|
changelog_uri: https://github.com/yykamei/rails_band/blob/main/CHANGELOG.md
|
116
|
+
rubygems_mfa_required: 'true'
|
91
117
|
post_install_message:
|
92
118
|
rdoc_options: []
|
93
119
|
require_paths:
|
@@ -103,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
129
|
- !ruby/object:Gem::Version
|
104
130
|
version: '0'
|
105
131
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.3.7
|
107
133
|
signing_key:
|
108
134
|
specification_version: 4
|
109
135
|
summary: Easy-to-use Rails Instrumentation API
|