cable_room 0.7.0.beta3 → 0.8.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -1287
- data/cable_room.gemspec +2 -5
- data/lib/cable_room/host/action_cable_inbound.rb +35 -0
- data/lib/cable_room/host/runner.rb +109 -391
- data/lib/cable_room/host/worker_pool.rb +27 -40
- data/lib/cable_room/host.rb +18 -364
- data/lib/cable_room/ports.rb +9 -19
- data/lib/cable_room/railtie.rb +11 -3
- data/lib/cable_room/room/base.rb +41 -40
- data/lib/cable_room/room/callbacks.rb +0 -22
- data/lib/cable_room/room/host_adapter.rb +4 -9
- data/lib/cable_room/room/lifecycle.rb +6 -23
- data/lib/cable_room/room/port_management.rb +0 -50
- data/lib/cable_room/room/reaping.rb +0 -33
- data/lib/cable_room/room/user_management.rb +0 -27
- data/lib/cable_room/room.rb +1 -4
- data/lib/cable_room/room_member.rb +84 -275
- data/lib/cable_room/room_proxy_channel.rb +2 -13
- data/lib/cable_room/version.rb +1 -1
- data/lib/cable_room.rb +0 -55
- metadata +7 -21
- data/CHANGELOG.md +0 -122
- data/exe/cable_room +0 -8
- data/lib/cable_room/broadcaster.rb +0 -116
- data/lib/cable_room/bus.rb +0 -372
- data/lib/cable_room/cli.rb +0 -237
- data/lib/cable_room/config.rb +0 -112
- data/lib/cable_room/host/bus_inbound.rb +0 -36
- data/lib/cable_room/host/supervisor.rb +0 -275
- data/lib/cable_room/membership_store.rb +0 -105
- data/lib/cable_room/migration.rb +0 -586
- data/lib/cable_room/placement.rb +0 -260
- data/lib/cable_room/room/snapshotting.rb +0 -82
- data/lib/cable_room/room_harness.rb +0 -168
- data/lib/cable_room/snapshot.rb +0 -136
data/cable_room.gemspec
CHANGED
|
@@ -18,17 +18,14 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.summary = "Build live Rooms on top of ActionCable"
|
|
19
19
|
spec.homepage = "https://instructure.com"
|
|
20
20
|
|
|
21
|
-
spec.files = Dir["{app,config,db,
|
|
22
|
-
spec.bindir = "exe"
|
|
23
|
-
spec.executables = ["cable_room"]
|
|
21
|
+
spec.files = Dir["{app,config,db,lib}/**/*", "README.md", "*.gemspec"]
|
|
24
22
|
spec.require_paths = ['lib']
|
|
25
23
|
|
|
26
24
|
spec.add_dependency "rails", ">= 7.2", "< 9.0"
|
|
27
25
|
spec.add_dependency "rufus-scheduler", "~> 3.6"
|
|
28
26
|
spec.add_dependency "redlock", "~> 2.0"
|
|
29
27
|
spec.add_dependency "rediconn", "~> 0.1.2"
|
|
30
|
-
# rediconn builds pools of redis-rb clients but doesn't declare the gem; the Bus needs it too
|
|
31
|
-
spec.add_dependency "redis", ">= 5.0"
|
|
32
28
|
|
|
29
|
+
spec.add_development_dependency "redis"
|
|
33
30
|
spec.add_development_dependency 'rspec', '~> 3'
|
|
34
31
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module CableRoom
|
|
2
|
+
class Host
|
|
3
|
+
# How rooms receive messages: straight off ActionCable's pubsub adapter, on the same stream
|
|
4
|
+
# names members publish to (Room::Base.room_port_key). This is the only place the room side
|
|
5
|
+
# touches ActionCable for inbound traffic; anything with the same two methods can be handed to
|
|
6
|
+
# `Host.new(inbound:)`.
|
|
7
|
+
#
|
|
8
|
+
# `subscribe` returns a handle that `unsubscribe` needs back. Handlers receive the payload
|
|
9
|
+
# exactly as published (a JSON string, for ActionCable) on the adapter's own thread, so they
|
|
10
|
+
# must be quick and hand the real work off. Host::Runner does that by queueing it on the room.
|
|
11
|
+
# `on_live` runs on that same thread once the adapter confirms the subscription.
|
|
12
|
+
class ActionCableInbound
|
|
13
|
+
# Subscribes from the calling thread. ActionCable's own stream_from posts the subscribe to
|
|
14
|
+
# the event loop first, but the adapter registers asynchronously either way, so that extra
|
|
15
|
+
# hop only widens the window in which the room can't hear anything.
|
|
16
|
+
#
|
|
17
|
+
# The adapter calls `on_live` while holding its own subscriber-map lock, so it must never
|
|
18
|
+
# wait on anything that might be waiting on the adapter (a room's mutex, say).
|
|
19
|
+
def subscribe(stream, on_live: nil, &on_message)
|
|
20
|
+
server.pubsub.subscribe(stream, on_message, on_live)
|
|
21
|
+
on_message
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def unsubscribe(stream, handle)
|
|
25
|
+
server.pubsub.unsubscribe(stream, handle)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def server
|
|
31
|
+
ActionCable.server
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|