feat(counter): add Redis counter adapter, replace DrbCounter
- Add Mozo::Counter::Redis with same get/set/incr/decr interface - Add redis gem (~> 5.0) to Gemfile - Update cable.yml to use Redis adapter in production (shared with counters) - Document DrbCounter → Redis migration in broadcasting-migration.md - Redis installed and running on vmi3300327 - Leave Faye as current broadcaster; both switches are one-line changes DrbCounter problems solved: - In-memory → persistent (RDB + AOF) - Single-process DRb → multi-process safe Redis - Atomic INCR/DECR across Puma workers - One less custom process to manage
This commit is contained in:
+7
-8
@@ -1,9 +1,9 @@
|
||||
# ActionCable configuration for real-time broadcasting.
|
||||
#
|
||||
# Development/Test: async adapter (in-process, no external dependency).
|
||||
# Production: async is fine for single-server deployments.
|
||||
# Switch to Redis (`redis://...`) if scaling to multiple Puma workers
|
||||
# where broadcasts need to reach clients connected to different workers.
|
||||
# Development: async adapter (in-process, no external dependency).
|
||||
# Test: test adapter.
|
||||
# Production: Redis adapter — required for multi-worker deployments.
|
||||
# Redis is also used for Mozo::Counter (replacing DrbCounter).
|
||||
#
|
||||
development:
|
||||
adapter: async
|
||||
@@ -12,7 +12,6 @@ test:
|
||||
adapter: test
|
||||
|
||||
production:
|
||||
adapter: async
|
||||
# adapter: redis
|
||||
# url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
||||
# channel_prefix: mozo_backend_production
|
||||
adapter: redis
|
||||
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
||||
channel_prefix: mozo_backend
|
||||
|
||||
@@ -8,12 +8,12 @@ else
|
||||
Mozo.user_url = 'https://user.mozo.bar'
|
||||
end
|
||||
|
||||
# Broadcaster: swap Faye ↔ ActionCable
|
||||
# Mozo.broadcaster = Mozo::Broadcaster::Faye.new # current (HTTP POST to Faye)
|
||||
# Mozo.broadcaster = Mozo::Broadcaster::ActionCable.new # new (in-process async)
|
||||
Mozo.broadcaster = Mozo::Broadcaster::Faye.new
|
||||
|
||||
# use the connection from couchbase-structures/documents
|
||||
# will be overwritten in the specs since flushing the real
|
||||
# thing is difficult
|
||||
# Mozo::Counter.connection = $cb unless Rails.env.test?
|
||||
|
||||
# Use the Drb counter
|
||||
# Counter: swap DrbCounter ↔ Redis
|
||||
# Mozo::Counter.connection = Mozo::DrbCounter.object # current (DRb in-memory)
|
||||
# Mozo::Counter.connection = Mozo::Counter::Redis.new # new (persistent, multi-process)
|
||||
Mozo::Counter.connection = Mozo::DrbCounter.object unless Rails.env.test?
|
||||
|
||||
Reference in New Issue
Block a user