Class: CableRoom::ChannelTracker::ThreadPool
- Inherits:
-
ActionCable::Server::Worker
- Object
- ActionCable::Server::Worker
- CableRoom::ChannelTracker::ThreadPool
- Defined in:
- lib/cable_room/channel_tracker.rb
Instance Method Summary collapse
- #async_invoke(receiver, method, *args, connection: receiver, &block) ⇒ Object
-
#invoke(receiver, method, *args, connection:, &block) ⇒ Object
ActionCable's Worker#invoke reduces every exception to a log line and a no-argument
handle_exceptioncall, which discards the error itself.
Instance Method Details
#async_invoke(receiver, method, *args, connection: receiver, &block) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cable_room/channel_tracker.rb', line 114 def async_invoke(receiver, method, *args, connection: receiver, &block) # Instead of posting directly to the global pool, post to a dedicated queue for the room/"connection". # This makes each rooms so that they can be processed by at-most-one thread at a time, while still # allowing multiple rooms to be processed by the same thread-pool. # TODO Implement more of a round-robin approach so that no room can starve out others? # "connection" here really references the Channel, since "Connections" in this context don't really exist connection._post_wrapped_work(async: false) do invoke(receiver, method, *args, connection: connection, &block) end end |
#invoke(receiver, method, *args, connection:, &block) ⇒ Object
ActionCable's Worker#invoke reduces every exception to a log line and a no-argument
handle_exception call, which discards the error itself. Rooms run all of their work
through here, so report it properly instead.
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/cable_room/channel_tracker.rb', line 100 def invoke(receiver, method, *args, connection:, &block) work(connection) do receiver.send method, *args, &block rescue Exception => e if connection.respond_to?(:report_work_error) connection.report_work_error(e) else logger.error "There was an exception - #{e.class}(#{e.})" logger.error Array(e.backtrace).join("\n") CableRoom.report_error(e, connection: connection) end end end |