rails_band 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba808adbe0481a5e503e5a8bd5e621bdc3d40b08c6166081277546b7773a3291
4
- data.tar.gz: 1795c39ac09d86aa3840364eb9a5266503f41933654c95202eb1aaf6ce737ba7
3
+ metadata.gz: 0073c31fe4ae49236f41f30bae3c61a320bfa607fd39c226e12a7810589df459
4
+ data.tar.gz: 7760001b63befc4473c1cafbfcb922889a2e3220feaf6e7b8331350f5b9c64a7
5
5
  SHA512:
6
- metadata.gz: cf0b8203cf992058b1a02257d5f7ffa873bfcf0e26e63786f869272085f50459ac3fb0a26ddc603210f009160afe623251272d78786f2d6aec7537968346b74c
7
- data.tar.gz: cf539bdb9ddb74150f5551ce9e87f7ec2c92130a36ec4ce6987a72cca2845813dce5ce86dde8a8d97403558a80e24d19f74d182689d8dd1689ca134227154bca
6
+ metadata.gz: b435e0f992b2ce887ee91b756cd60ad41083e4c3c54d15cf84cf727b456e6c91dad4989d1ab2bfc402e609675dd83bd7413881b358761368a2f8666a47a749e1
7
+ data.tar.gz: b07118dbe958e4de5cd426564ab62e3cdedfb65bbf8779b8df74bef9536b8836c811a79ea6d72e12eb75dd277292f7c94c6645271583b477c80cdc067ec917e8
data/README.md CHANGED
@@ -94,6 +94,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
94
94
  | `strict_loading_violation.active_record` (Not yet documented. See the configuration of `action_on_strict_loading_violation`) | ✅ |
95
95
  | [`sql.active_record`](https://guides.rubyonrails.org/active_support_instrumentation.html#sql-active-record) | ✅ |
96
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) | |
97
98
 
98
99
  ### Action Mailer
99
100
 
@@ -112,20 +113,20 @@ These are Rails Instrumentation API hooks supported by this gem so far.
112
113
  | [`cache_fetch_hit.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-fetch-hit-active-support) | ✅ |
113
114
  | [`cache_write.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-write-active-support) | ✅ |
114
115
  | [`cache_write_multi.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-write-multi-active-support) | ✅ |
115
- | [`cache_increment.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-increment-active-support) | |
116
- | [`cache_decrement.active_support `](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-decrement-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) ||
117
118
  | [`cache_delete.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-delete-active-support) | ✅ |
118
119
  | [`cache_delete_multi.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-delete-multi-active-support) | ✅ |
119
- | [`cache_delete_matched.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-delete-matched-active-support) | |
120
- | [`cache_cleanup.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-cleanup-active-support) | |
121
- | [`cache_prune.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#cache-prune-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) ||
122
123
  | [`cache_exist?.active_support`](https://guides.rubyonrails.org/active_support_instrumentation.html#cache-exist-questionmark-active-support) | ✅ |
123
124
 
124
125
  ### Active Support — Messages
125
126
 
126
127
  | Event name | Supported |
127
128
  | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
128
- | [`message_serializer_fallback.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#message-serializer-fallback-active-support) | |
129
+ | [`message_serializer_fallback.active_support`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#message-serializer-fallback-active-support) ||
129
130
 
130
131
  ### Active Job
131
132
 
@@ -171,7 +172,7 @@ These are Rails Instrumentation API hooks supported by this gem so far.
171
172
 
172
173
  | Event name | Supported |
173
174
  | ------------------------------------------------------------------------------------------------------------------------- | --------- |
174
- | [`process.action_mailbox`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#process-action-mailbox) | |
175
+ | [`process.action_mailbox`](https://edgeguides.rubyonrails.org/active_support_instrumentation.html#process-action-mailbox) ||
175
176
 
176
177
  ### Railties
177
178
 
@@ -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.10.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.10.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-04-24 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
@@ -64,6 +64,8 @@ files:
64
64
  - lib/rails_band/action_dispatch/event/redirect.rb
65
65
  - lib/rails_band/action_dispatch/event/request.rb
66
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
67
69
  - lib/rails_band/action_mailer/event/deliver.rb
68
70
  - lib/rails_band/action_mailer/event/process.rb
69
71
  - lib/rails_band/action_mailer/log_subscriber.rb
@@ -99,15 +101,21 @@ files:
99
101
  - lib/rails_band/active_storage/event/service_url.rb
100
102
  - lib/rails_band/active_storage/event/transform.rb
101
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
102
106
  - lib/rails_band/active_support/event/cache_delete.rb
107
+ - lib/rails_band/active_support/event/cache_delete_matched.rb
103
108
  - lib/rails_band/active_support/event/cache_delete_multi.rb
104
109
  - lib/rails_band/active_support/event/cache_exist.rb
105
110
  - lib/rails_band/active_support/event/cache_fetch_hit.rb
106
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
107
114
  - lib/rails_band/active_support/event/cache_read.rb
108
115
  - lib/rails_band/active_support/event/cache_read_multi.rb
109
116
  - lib/rails_band/active_support/event/cache_write.rb
110
117
  - lib/rails_band/active_support/event/cache_write_multi.rb
118
+ - lib/rails_band/active_support/event/message_serializer_fallback.rb
111
119
  - lib/rails_band/active_support/log_subscriber.rb
112
120
  - lib/rails_band/base_event.rb
113
121
  - lib/rails_band/configuration.rb
@@ -136,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
144
  - !ruby/object:Gem::Version
137
145
  version: '0'
138
146
  requirements: []
139
- rubygems_version: 3.5.9
147
+ rubygems_version: 3.5.11
140
148
  signing_key:
141
149
  specification_version: 4
142
150
  summary: Easy-to-use Rails Instrumentation API