0.0
No commit activity in last 3 years
No release in over 3 years
Broadcasting based on Redis PubSub
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.8
~> 5.0, < 5.11
~> 0.2
~> 12.0
~> 0.12

Runtime

~> 1.5
 Project Readme

Broadcaster

Gem Version Build Status Coverage Status Code Climate

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_settings = 'redis://host_name:6379'
  # or
  config.redis_client = Redic::Sentinels
  config.redis_settings = hosts: [sentinel_1, sentinel_2], master_name: 'mymaster'
end

Options

options = {
  id: 'my_app',                             # Shared broadcaster for multiple processes
  redis_settings: 'redis://host_name:6379', # Custom redis connection
  logger: Logger.new('/file.log')           # Custom logger
  # or
  redis_client: Redic::Sentinels,
  redis_settings: hosts: [sentinel_1, sentinel_2], master_name: 'mymaster'
}

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.