Module: Pubsubstub
- Extended by:
- Mutex_m
- Defined in:
- lib/pubsubstub.rb,
lib/pubsubstub/event.rb,
lib/pubsubstub/channel.rb,
lib/pubsubstub/logging.rb,
lib/pubsubstub/version.rb,
lib/pubsubstub/subscriber.rb,
lib/pubsubstub/application.rb,
lib/pubsubstub/subscription.rb,
lib/pubsubstub/stream_action.rb,
lib/pubsubstub/publish_action.rb
Defined Under Namespace
Modules: Logging, RedisPubSub Classes: Application, Channel, Event, PublishAction, StreamAction, Subscriber, Subscription
Constant Summary collapse
- VERSION =
"0.3.0"
Class Attribute Summary collapse
-
.channels_scrollback_size ⇒ Object
Returns the value of attribute channels_scrollback_size.
-
.channels_scrollback_ttl ⇒ Object
Returns the value of attribute channels_scrollback_ttl.
-
.error_handler ⇒ Object
Returns the value of attribute error_handler.
-
.heartbeat_frequency ⇒ Object
Returns the value of attribute heartbeat_frequency.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.reconnect_timeout ⇒ Object
Returns the value of attribute reconnect_timeout.
-
.redis_url ⇒ Object
Returns the value of attribute redis_url.
-
.use_persistent_connections ⇒ Object
Returns the value of attribute use_persistent_connections.
Class Method Summary collapse
- .handle_error(error) ⇒ Object
- .heartbeat_event ⇒ Object
- .new_redis ⇒ Object
- .publish(channel_name, *args) ⇒ Object
- .redis ⇒ Object
- .redis=(client) ⇒ Object
- .report_errors ⇒ Object
- .subscriber ⇒ Object
Class Attribute Details
.channels_scrollback_size ⇒ Object
Returns the value of attribute channels_scrollback_size.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def channels_scrollback_size @channels_scrollback_size end |
.channels_scrollback_ttl ⇒ Object
Returns the value of attribute channels_scrollback_ttl.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def channels_scrollback_ttl @channels_scrollback_ttl end |
.error_handler ⇒ Object
Returns the value of attribute error_handler.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def error_handler @error_handler end |
.heartbeat_frequency ⇒ Object
Returns the value of attribute heartbeat_frequency.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def heartbeat_frequency @heartbeat_frequency end |
.logger ⇒ Object
Returns the value of attribute logger.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def logger @logger end |
.reconnect_timeout ⇒ Object
Returns the value of attribute reconnect_timeout.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def reconnect_timeout @reconnect_timeout end |
.redis_url ⇒ Object
Returns the value of attribute redis_url.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def redis_url @redis_url end |
.use_persistent_connections ⇒ Object
Returns the value of attribute use_persistent_connections.
23 24 25 |
# File 'lib/pubsubstub.rb', line 23 def use_persistent_connections @use_persistent_connections end |
Class Method Details
.handle_error(error) ⇒ Object
57 58 59 60 |
# File 'lib/pubsubstub.rb', line 57 def handle_error(error) logger.error("Uncaught exception: #{error.class}: #{error.}\n#{error.backtrace.join("\n\t")}\n") error_handler && error_handler.call(error) end |
.heartbeat_event ⇒ Object
53 54 55 |
# File 'lib/pubsubstub.rb', line 53 def heartbeat_event Event.new('ping', name: 'heartbeat', retry_after: reconnect_timeout) end |
.new_redis ⇒ Object
45 46 47 |
# File 'lib/pubsubstub.rb', line 45 def new_redis Redis.new(url: redis_url) end |
.publish(channel_name, *args) ⇒ Object
27 28 29 30 |
# File 'lib/pubsubstub.rb', line 27 def publish(channel_name, *args) Channel.new(channel_name).publish(Event.new(*args)) nil end |
.redis ⇒ Object
37 38 39 |
# File 'lib/pubsubstub.rb', line 37 def redis @redis || synchronize { @redis ||= new_redis } end |
.redis=(client) ⇒ Object
41 42 43 |
# File 'lib/pubsubstub.rb', line 41 def redis=(client) synchronize { @redis = client } end |
.report_errors ⇒ Object
62 63 64 65 66 67 |
# File 'lib/pubsubstub.rb', line 62 def report_errors yield rescue => error handle_error(error) raise end |
.subscriber ⇒ Object
49 50 51 |
# File 'lib/pubsubstub.rb', line 49 def subscriber @subscriber || synchronize { @subscriber ||= Subscriber.new } end |