Sha256: a463ed8618a589a25f0f649829cfcbe04560a4d51b35fc51bbdecc5a69aea68f
Contents?: true
Size: 967 Bytes
Versions: 6
Compression:
Stored size: 967 Bytes
Contents
# frozen_string_literal: true gem "redis", ">= 3" require "redis" require "json" module AnyCable module BroadcastAdapters # Redis adapter for broadcasting. # # Example: # # AnyCable.broadast_adapter = :redis # # It uses Redis configuration from global AnyCable config # by default. # # You can override these params: # # AnyCable.broadcast_adapter = :redis, url: "redis://my_redis", channel: "_any_cable_" class Redis < Base attr_reader :redis_conn, :channel def initialize( channel: AnyCable.config.redis_channel, **options ) options = AnyCable.config.to_redis_params.merge(options) @redis_conn = ::Redis.new(options) @channel = channel end def raw_broadcast(payload) redis_conn.publish(channel, payload) end def announce! logger.info "Broadcasting Redis channel: #{channel}" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems