Class: ActionCable::Server::Worker

Inherits:
Object
  • Object
show all
Includes:
ClearDatabaseConnections, ActiveSupport::Callbacks, Celluloid
Defined in:
lib/action_cable/server/worker.rb,
lib/action_cable/server/worker/clear_database_connections.rb

Overview

Worker used by Server.send_async to do connection work in threads. Only for internal use.

Defined Under Namespace

Modules: ClearDatabaseConnections

Instance Method Summary collapse

Methods included from ClearDatabaseConnections

#with_database_connections

Instance Method Details

#invoke(receiver, method, *args) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/action_cable/server/worker.rb', line 11

def invoke(receiver, method, *args)
  run_callbacks :work do
    receiver.send method, *args
  end
rescue Exception => e
  logger.error "There was an exception - #{e.class}(#{e.message})"
  logger.error e.backtrace.join("\n")

  receiver.handle_exception if receiver.respond_to?(:handle_exception)
end

#run_periodic_timer(channel, callback) ⇒ Object


22
23
24
25
26
# File 'lib/action_cable/server/worker.rb', line 22

def run_periodic_timer(channel, callback)
  run_callbacks :work do
    callback.respond_to?(:call) ? channel.instance_exec(&callback) : channel.send(callback)
  end
end