Module: Pubsubstub
- Extended by:
- Mutex_m
- Defined in:
- lib/pubsubstub.rb,
lib/pubsubstub/event.rb,
lib/pubsubstub/action.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: Action, Application, Channel, Event, PublishAction, StreamAction, Subscriber, Subscription
Constant Summary collapse
- VERSION =
"0.1.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.
Class Method Summary collapse
- .handle_error(error) ⇒ Object
- .heartbeat_event ⇒ Object
- .new_redis ⇒ Object
- .publish(channel_name, *args) ⇒ Object
- .redis ⇒ 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 |
Class Method Details
.handle_error(error) ⇒ Object
52 53 54 55 |
# File 'lib/pubsubstub.rb', line 52 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
48 49 50 |
# File 'lib/pubsubstub.rb', line 48 def heartbeat_event Event.new('ping', name: 'heartbeat', retry_after: reconnect_timeout) end |
.new_redis ⇒ Object
40 41 42 |
# File 'lib/pubsubstub.rb', line 40 def new_redis Redis.new(url: redis_url) end |
.publish(channel_name, *args) ⇒ Object
26 27 28 29 |
# File 'lib/pubsubstub.rb', line 26 def publish(channel_name, *args) Channel.new(channel_name).publish(Event.new(*args)) nil end |
.redis ⇒ Object
36 37 38 |
# File 'lib/pubsubstub.rb', line 36 def redis @redis || synchronize { @redis ||= new_redis } end |
.report_errors ⇒ Object
57 58 59 60 61 62 |
# File 'lib/pubsubstub.rb', line 57 def report_errors yield rescue => error handle_error(error) raise end |
.subscriber ⇒ Object
44 45 46 |
# File 'lib/pubsubstub.rb', line 44 def subscriber @subscriber || synchronize { @subscriber ||= Subscriber.new } end |