Module: CableRoom

Defined in:
lib/cable_room.rb,
lib/cable_room/room.rb,
lib/cable_room/ports.rb,
lib/cable_room/railtie.rb,
lib/cable_room/version.rb,
lib/cable_room/room/base.rb,
lib/cable_room/room_member.rb,
lib/cable_room/channel_base.rb,
lib/cable_room/room/reaping.rb,
lib/cable_room/room/callbacks.rb,
lib/cable_room/room/lifecycle.rb,
lib/cable_room/room/threading.rb,
lib/cable_room/channel_tracker.rb,
lib/cable_room/room/broadcasting.rb,
lib/cable_room/room/port_scoping.rb,
lib/cable_room/room/port_policies.rb,
lib/cable_room/room_proxy_channel.rb,
lib/cable_room/room/input_handling.rb,
lib/cable_room/room/channel_adapter.rb,
lib/cable_room/room/port_management.rb,
lib/cable_room/room/user_management.rb

Defined Under Namespace

Modules: Ports, Room, RoomMember, RoomProxyChannel Classes: ChannelBase, ChannelTracker, DummyConnection, PeriodicTimer, Railtie, RoomMembership

Constant Summary collapse

VERSION =
"0.6.0".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.error_handlerObject

Called as handler.call(error, context) whenever work inside a Room raises. Rooms swallow exceptions so that one bad message can't kill the Room, which makes this the only way to find out that it happened. Set it to forward to your error reporter:

CableRoom.error_handler = ->(error, context) { Sentry.capture_exception(error, extra: context) }

An "error.cable_room" ActiveSupport notification is emitted regardless.



29
30
31
# File 'lib/cable_room.rb', line 29

def error_handler
  @error_handler
end

Class Method Details

.lock_managerObject



48
49
50
51
52
# File 'lib/cable_room.rb', line 48

def lock_manager
  @lock_manager ||= Redlock::Client.new([
    CableRoom.redis,
  ])
end

.redis(&blk) ⇒ Object



44
45
46
# File 'lib/cable_room.rb', line 44

def redis(&blk)
  redis_pool.lazy_with(&blk)
end

.redis_poolObject



39
40
41
42
# File 'lib/cable_room.rb', line 39

def redis_pool
  require 'rediconn'
  @redis_pool ||= RediConn::RedisConnection.create(env_prefix: "CABLEROOM")
end

.report_error(error, **context) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/cable_room.rb', line 31

def report_error(error, **context)
  ActiveSupport::Notifications.instrument("error.cable_room", { error: error, **context })
  error_handler&.call(error, context)
rescue => handler_error
  # A broken reporter must never mask the failure it was reporting
  warn "CableRoom.error_handler raised #{handler_error.class}: #{handler_error.message}"
end