Class: AnyCable::Rails::Middlewares::Executor
- Inherits:
-
Middleware
- Object
- Middleware
- AnyCable::Rails::Middlewares::Executor
- Defined in:
- lib/anycable/rails/middlewares/executor.rb
Overview
Executor runs Rails executor for each call See guides.rubyonrails.org/v5.2.0/threading_and_code_execution.html#framework-behavior
Instance Attribute Summary collapse
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
Instance Method Summary collapse
- #call(method, message, metadata) ⇒ Object
-
#initialize(executor) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(executor) ⇒ Executor
11 12 13 |
# File 'lib/anycable/rails/middlewares/executor.rb', line 11 def initialize(executor) @executor = executor end |
Instance Attribute Details
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
9 10 11 |
# File 'lib/anycable/rails/middlewares/executor.rb', line 9 def executor @executor end |
Instance Method Details
#call(method, message, metadata) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/anycable/rails/middlewares/executor.rb', line 15 def call(method, , ) sid = ["sid"] if ::Rails.respond_to?(:error) executor.wrap do ::Rails.error.record(context: {method: method, payload: .to_h, sid: sid}) do Rails.with_socket_id(sid) { yield } end end else executor.wrap { Rails.with_socket_id(sid) { yield } } end end |