Sha256: 125353b94b1ffd47693242f8710168073a72e6da1269fdc249ae34a47356f1ea

Contents?: true

Size: 418 Bytes

Versions: 7

Compression:

Stored size: 418 Bytes

Contents

# frozen_string_literal: true
require "redis"
require "json"

module Anycable
  # PubSub for broadcasting
  class PubSub
    attr_reader :redis_conn

    def initialize
      @redis_conn = Redis.new(url: Anycable.config.redis_url)
    end

    def broadcast(channel, payload)
      redis_conn.publish(
        Anycable.config.redis_channel,
        { stream: channel, data: payload }.to_json
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
anycable-0.4.6 lib/anycable/pubsub.rb
anycable-0.4.5 lib/anycable/pubsub.rb
anycable-0.4.4 lib/anycable/pubsub.rb
anycable-0.4.3 lib/anycable/pubsub.rb
anycable-0.4.2 lib/anycable/pubsub.rb
anycable-0.4.1 lib/anycable/pubsub.rb
anycable-0.4.0 lib/anycable/pubsub.rb