Broadcaster

Gem Version Build Status Coverage Status Code Climate Dependency Status

Broadcasting based on Redis PubSub

Installation

Add this line to your application's Gemfile:

gem 'broadcaster'

And then execute:

$ bundle

Or install it yourself as:

$ gem install broadcaster

Usage

broadcaster = Broadcaster.new

subscription_id = broadcaster.subscribe 'channel_1' do |message|
  puts message
end

broadcaster.publish 'channel_1', 'text'
broadcaster.publish 'channel_1', 1
broadcaster.publish 'channel_1', key: 'value'

broadcaster.unsubscribe subscription_id
broadcaster.unsubscribe_all

Global configuration

Broadcaster.configure do |config|
  config.logger = Logger.new '/file.log'
  config.redis_url = 'redis://host_name:6379'
end

Options

options = {
  id: 'my_app',                         # Shared broadcaster for multiple processes
  redis_url: 'redis://host_name:6379',  # Custom redis connection
  logger: Logger.new('/file.log')       # Custom logger
}

Broadcaster.new options

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/broadcaster.

License

The gem is available as open source under the terms of the MIT License.