rails_band 0.9.0 → 0.11.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34881b30e4915c22757b49f247fcc759cdffded452f6f7ac2951fed5500d95b9
4
- data.tar.gz: 53e59f258f2cbbffc68d461a28490a39164915115902be3fbb4bec12a03383bb
3
+ metadata.gz: 0073c31fe4ae49236f41f30bae3c61a320bfa607fd39c226e12a7810589df459
4
+ data.tar.gz: 7760001b63befc4473c1cafbfcb922889a2e3220feaf6e7b8331350f5b9c64a7
5
5
  SHA512:
6
- metadata.gz: 3780f2f7fd5fcdfeb98fc45ffb37578c53c0fb88bdb9bfd9ca6acd88241e6d9597a41fdac2bc7f7e47852a0c5f8e6d11db8db132478d99d3609d3d6b401cf49a
7
- data.tar.gz: 056bbf55db47f21019af355e89dc7de001d71a45c67a219e4836ed37014e43b45b142ee73b3ee0fc44366e84865490e37447e90f572ca99a59ef89e210e357b4
6
+ metadata.gz: b435e0f992b2ce887ee91b756cd60ad41083e4c3c54d15cf84cf727b456e6c91dad4989d1ab2bfc402e609675dd83bd7413881b358761368a2f8666a47a749e1
7
+ data.tar.gz: b07118dbe958e4de5cd426564ab62e3cdedfb65bbf8779b8df74bef9536b8836c811a79ea6d72e12eb75dd277292f7c94c6645271583b477c80cdc067ec917e8
data/README.md CHANGED
@@ -76,6 +76,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
76
76
  | --------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
77
77
  | [`process_middleware.action_dispatch`](https://guides.rubyonrails.org/active_support_instrumentation.html#process-middleware-action-dispatch) | ✅ |
78
78
  | [`redirect.action_dispatch`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#redirect-action-dispatch) | ✅ |
79
+ | [`request.action_dispatch`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#request-action-dispatch) | ✅ |
79
80
 
80
81
  ### Action View
81
82
 
@@ -93,6 +94,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
93
94
  | `strict_loading_violation.active_record` (Not yet documented. See the configuration of `action_on_strict_loading_violation`) | ✅ |
94
95
  | [`sql.active_record`](https://guides.rubyonrails.org/active_support_instrumentation.html#sql-active-record) | ✅ |
95
96
  | [`instantiation.active_record`](https://guides.rubyonrails.org/active_support_instrumentation.html#instantiation-active-record) | ✅ |
97
+ | [`transaction.active_record`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#transaction-active-record) | |
96
98
 
97
99
  ### Action Mailer
98
100
 
@@ -101,19 +103,30 @@ These are Rails Instrumentation API hooks supported by this gem so far.
101
103
  | [`deliver.action_mailer`](https://guides.rubyonrails.org/active_support_instrumentation.html#deliver-action-mailer) | ✅ |
102
104
  | [`process.action_mailer`](https://guides.rubyonrails.org/active_support_instrumentation.html#process-action-mailer) | ✅ |
103
105
 
104
- ### Active Support
105
-
106
- | Event name | Supported |
107
- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
108
- | [`cache_read.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-read-active-support) | ✅ |
109
- | `cache_read_multi.active_support` (Not yet documented) | ✅ |
110
- | [`cache_generate.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-generate-active-support) | ✅ |
111
- | [`cache_fetch_hit.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-fetch-hit-active-support) | ✅ |
112
- | [`cache_write.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-write-active-support) | ✅ |
113
- | `cache_write_multi.active_support` (Not yet documented) | ✅ |
114
- | [`cache_delete.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-delete-active-support) | ✅ |
115
- | `cache_delete_multi.active_support` (Not yet documented, supported since Rails 6.1) | ✅ |
116
- | [`cache_exist?.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-exist-questionmark-active-support) | ✅ |
106
+ ### Active Support — Caching
107
+
108
+ | Event name | Supported |
109
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
110
+ | [`cache_read.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-read-active-support) | ✅ |
111
+ | [`cache_read_multi.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-read-multi-active-support) | ✅ |
112
+ | [`cache_generate.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-generate-active-support) | ✅ |
113
+ | [`cache_fetch_hit.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-fetch-hit-active-support) | ✅ |
114
+ | [`cache_write.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-write-active-support) | ✅ |
115
+ | [`cache_write_multi.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-write-multi-active-support) | ✅ |
116
+ | [`cache_increment.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-increment-active-support) | ✅ |
117
+ | [`cache_decrement.active_support `](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-decrement-active-support) | ✅ |
118
+ | [`cache_delete.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-delete-active-support) | ✅ |
119
+ | [`cache_delete_multi.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-delete-multi-active-support) | ✅ |
120
+ | [`cache_delete_matched.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-delete-matched-active-support) | ✅ |
121
+ | [`cache_cleanup.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-cleanup-active-support) | ✅ |
122
+ | [`cache_prune.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-prune-active-support) | ✅ |
123
+ | [`cache_exist?.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-exist-questionmark-active-support) | ✅ |
124
+
125
+ ### Active Support — Messages
126
+
127
+ | Event name | Supported |
128
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
129
+ | [`message_serializer_fallback.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#message-serializer-fallback-active-support) | ✅ |
117
130
 
118
131
  ### Active Job
119
132
 
@@ -155,6 +168,12 @@ These are Rails Instrumentation API hooks supported by this gem so far.
155
168
  | [`transform.active_storage`](https://guides.rubyonrails.org/active_support_instrumentation.html#transform-active-storage) | ✅ |
156
169
  | [`analyze.active_storage`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#analyze-active-storage) | ✅ |
157
170
 
171
+ ### Action Mailbox
172
+
173
+ | Event name | Supported |
174
+ | ------------------------------------------------------------------------------------------------------------------------- | --------- |
175
+ | [`process.action_mailbox`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#process-action-mailbox) | ✅ |
176
+
158
177
  ### Railties
159
178
 
160
179
  | Event name | Supported |
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionDispatch
5
+ module Event
6
+ # A wrapper for the event that is passed to `redirect.action_dispatch`.
7
+ class Request < BaseEvent
8
+ def request
9
+ @request ||= @event.payload.fetch(:request)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rails_band/action_dispatch/event/process_middleware'
4
4
  require 'rails_band/action_dispatch/event/redirect'
5
+ require 'rails_band/action_dispatch/event/request'
5
6
 
6
7
  module RailsBand
7
8
  module ActionDispatch
@@ -17,6 +18,10 @@ module RailsBand
17
18
  consumer_of(__method__)&.call(Event::Redirect.new(event))
18
19
  end
19
20
 
21
+ def request(event)
22
+ consumer_of(__method__)&.call(Event::Request.new(event))
23
+ end
24
+
20
25
  private
21
26
 
22
27
  def consumer_of(sub_event)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActionMailbox
5
+ module Event
6
+ # A wrapper for the event that is passed to `process.action_mailbox`.
7
+ class Process < BaseEvent
8
+ def mailbox
9
+ @mailbox ||= @event.payload.fetch(:mailbox)
10
+ end
11
+
12
+ def inbound_email
13
+ @inbound_email ||= @event.payload.fetch(:inbound_email)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_band/action_mailbox/event/process'
4
+
5
+ module RailsBand
6
+ module ActionMailbox
7
+ # The custom LogSubscriber for ActionMailbox.
8
+ class LogSubscriber < ::ActiveSupport::LogSubscriber
9
+ mattr_accessor :consumers
10
+
11
+ def process(event)
12
+ consumer_of(__method__)&.call(Event::Process.new(event))
13
+ end
14
+
15
+ private
16
+
17
+ def consumer_of(sub_event)
18
+ consumers[:"#{sub_event}.action_mailbox"] || consumers[:action_mailbox] || consumers[:default]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveSupport
5
+ module Event
6
+ # A wrapper for the event that is passed to `cache_cleanup.active_support`.
7
+ class CacheCleanup < BaseEvent
8
+ def store
9
+ @store ||= @event.payload.fetch(:store)
10
+ end
11
+
12
+ def size
13
+ @size ||= @event.payload.fetch(:size)
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 ActiveSupport
5
+ module Event
6
+ # A wrapper for the event that is passed to `cache_decrement.active_support`.
7
+ class CacheDecrement < BaseEvent
8
+ def key
9
+ @key ||= @event.payload.fetch(:key)
10
+ end
11
+
12
+ def store
13
+ @store ||= @event.payload.fetch(:store)
14
+ end
15
+
16
+ def amount
17
+ @amount ||= @event.payload.fetch(:amount)
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 ActiveSupport
5
+ module Event
6
+ # A wrapper for the event that is passed to `cache_delete_matched.active_support`.
7
+ class CacheDeleteMatched < BaseEvent
8
+ def key
9
+ @key ||= @event.payload.fetch(:key)
10
+ end
11
+
12
+ def store
13
+ @store ||= @event.payload.fetch(:store)
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 ActiveSupport
5
+ module Event
6
+ # A wrapper for the event that is passed to `cache_increment.active_support`.
7
+ class CacheIncrement < BaseEvent
8
+ def key
9
+ @key ||= @event.payload.fetch(:key)
10
+ end
11
+
12
+ def store
13
+ @store ||= @event.payload.fetch(:store)
14
+ end
15
+
16
+ def amount
17
+ @amount ||= @event.payload.fetch(:amount)
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 ActiveSupport
5
+ module Event
6
+ # A wrapper for the event that is passed to `cache_prune.active_support`.
7
+ class CachePrune < BaseEvent
8
+ def store
9
+ @store ||= @event.payload.fetch(:store)
10
+ end
11
+
12
+ def key
13
+ @key ||= @event.payload.fetch(:key)
14
+ end
15
+
16
+ def from
17
+ @from ||= @event.payload.fetch(:from)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsBand
4
+ module ActiveSupport
5
+ module Event
6
+ # A wrapper for the event that is passed to `message_serializer_fallback.active_support`.
7
+ class MessageSerializerFallback < BaseEvent
8
+ def serializer
9
+ @serializer ||= @event.payload.fetch(:serializer)
10
+ end
11
+
12
+ def fallback
13
+ @fallback ||= @event.payload.fetch(:fallback)
14
+ end
15
+
16
+ def serialized
17
+ @serialized ||= @event.payload.fetch(:serialized)
18
+ end
19
+
20
+ def deserialized
21
+ @deserialized ||= @event.payload.fetch(:deserialized)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -6,9 +6,15 @@ require 'rails_band/active_support/event/cache_generate'
6
6
  require 'rails_band/active_support/event/cache_fetch_hit'
7
7
  require 'rails_band/active_support/event/cache_write'
8
8
  require 'rails_band/active_support/event/cache_write_multi'
9
+ require 'rails_band/active_support/event/cache_increment'
10
+ require 'rails_band/active_support/event/cache_decrement'
9
11
  require 'rails_band/active_support/event/cache_delete'
10
12
  require 'rails_band/active_support/event/cache_delete_multi'
13
+ require 'rails_band/active_support/event/cache_delete_matched'
14
+ require 'rails_band/active_support/event/cache_cleanup'
15
+ require 'rails_band/active_support/event/cache_prune'
11
16
  require 'rails_band/active_support/event/cache_exist'
17
+ require 'rails_band/active_support/event/message_serializer_fallback'
12
18
 
13
19
  module RailsBand
14
20
  module ActiveSupport
@@ -40,6 +46,14 @@ module RailsBand
40
46
  consumer_of(__method__)&.call(Event::CacheWriteMulti.new(event))
41
47
  end
42
48
 
49
+ def cache_increment(event)
50
+ consumer_of(__method__)&.call(Event::CacheIncrement.new(event))
51
+ end
52
+
53
+ def cache_decrement(event)
54
+ consumer_of(__method__)&.call(Event::CacheDecrement.new(event))
55
+ end
56
+
43
57
  def cache_delete(event)
44
58
  consumer_of(__method__)&.call(Event::CacheDelete.new(event))
45
59
  end
@@ -48,10 +62,26 @@ module RailsBand
48
62
  consumer_of(__method__)&.call(Event::CacheDeleteMulti.new(event))
49
63
  end
50
64
 
65
+ def cache_delete_matched(event)
66
+ consumer_of(__method__)&.call(Event::CacheDeleteMatched.new(event))
67
+ end
68
+
69
+ def cache_cleanup(event)
70
+ consumer_of(__method__)&.call(Event::CacheCleanup.new(event))
71
+ end
72
+
73
+ def cache_prune(event)
74
+ consumer_of(__method__)&.call(Event::CachePrune.new(event))
75
+ end
76
+
51
77
  def cache_exist?(event)
52
78
  consumer_of(__method__)&.call(Event::CacheExist.new(event))
53
79
  end
54
80
 
81
+ def message_serializer_fallback(event)
82
+ consumer_of(__method__)&.call(Event::MessageSerializerFallback.new(event))
83
+ end
84
+
55
85
  private
56
86
 
57
87
  def consumer_of(sub_event)
@@ -10,7 +10,7 @@ module RailsBand
10
10
  raise ArgumentError, "The value for `#{key.inspect}` must have #call: the passed one is `#{value.inspect}`"
11
11
  end
12
12
 
13
- super(key, value)
13
+ super
14
14
  end
15
15
  end
16
16
 
@@ -66,6 +66,11 @@ module RailsBand
66
66
  swap.call(::ActiveJob::LogSubscriber, RailsBand::ActiveJob::LogSubscriber, :active_job)
67
67
  end
68
68
  end
69
+
70
+ if defined?(::ActionMailbox)
71
+ RailsBand::ActionMailbox::LogSubscriber.consumers = consumers
72
+ RailsBand::ActionMailbox::LogSubscriber.attach_to :action_mailbox
73
+ end
69
74
  end
70
75
  end
71
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBand
4
- VERSION = '0.9.0'
4
+ VERSION = '0.11.0'
5
5
  end
data/lib/rails_band.rb CHANGED
@@ -53,4 +53,9 @@ module RailsBand
53
53
  module ActiveStorage
54
54
  autoload :LogSubscriber, 'rails_band/active_storage/log_subscriber'
55
55
  end
56
+
57
+ # RailsBand::ActionMailbox is responsible for subscribing notifications from ActionMailbox.
58
+ module ActionMailbox
59
+ autoload :LogSubscriber, 'rails_band/action_mailbox/log_subscriber'
60
+ end
56
61
  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.9.0
4
+ version: 0.11.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: 2024-03-14 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -62,7 +62,10 @@ files:
62
62
  - lib/rails_band/action_controller/log_subscriber.rb
63
63
  - lib/rails_band/action_dispatch/event/process_middleware.rb
64
64
  - lib/rails_band/action_dispatch/event/redirect.rb
65
+ - lib/rails_band/action_dispatch/event/request.rb
65
66
  - lib/rails_band/action_dispatch/log_subscriber.rb
67
+ - lib/rails_band/action_mailbox/event/process.rb
68
+ - lib/rails_band/action_mailbox/log_subscriber.rb
66
69
  - lib/rails_band/action_mailer/event/deliver.rb
67
70
  - lib/rails_band/action_mailer/event/process.rb
68
71
  - lib/rails_band/action_mailer/log_subscriber.rb
@@ -98,15 +101,21 @@ files:
98
101
  - lib/rails_band/active_storage/event/service_url.rb
99
102
  - lib/rails_band/active_storage/event/transform.rb
100
103
  - lib/rails_band/active_storage/log_subscriber.rb
104
+ - lib/rails_band/active_support/event/cache_cleanup.rb
105
+ - lib/rails_band/active_support/event/cache_decrement.rb
101
106
  - lib/rails_band/active_support/event/cache_delete.rb
107
+ - lib/rails_band/active_support/event/cache_delete_matched.rb
102
108
  - lib/rails_band/active_support/event/cache_delete_multi.rb
103
109
  - lib/rails_band/active_support/event/cache_exist.rb
104
110
  - lib/rails_band/active_support/event/cache_fetch_hit.rb
105
111
  - lib/rails_band/active_support/event/cache_generate.rb
112
+ - lib/rails_band/active_support/event/cache_increment.rb
113
+ - lib/rails_band/active_support/event/cache_prune.rb
106
114
  - lib/rails_band/active_support/event/cache_read.rb
107
115
  - lib/rails_band/active_support/event/cache_read_multi.rb
108
116
  - lib/rails_band/active_support/event/cache_write.rb
109
117
  - lib/rails_band/active_support/event/cache_write_multi.rb
118
+ - lib/rails_band/active_support/event/message_serializer_fallback.rb
110
119
  - lib/rails_band/active_support/log_subscriber.rb
111
120
  - lib/rails_band/base_event.rb
112
121
  - lib/rails_band/configuration.rb
@@ -135,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
144
  - !ruby/object:Gem::Version
136
145
  version: '0'
137
146
  requirements: []
138
- rubygems_version: 3.5.3
147
+ rubygems_version: 3.5.11
139
148
  signing_key:
140
149
  specification_version: 4
141
150
  summary: Easy-to-use Rails Instrumentation API