Sha256: ba30100c8fa24c9ae539186a1e9b0ef7cae195e619bdf9133dcee0571b44b092
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
class ForeignOffice::Busses::PubnubBus < ForeignOffice::Busses::GenericBus def self.publish_key=(publish_key) @publish_key = publish_key end def self.publish_key @publish_key end def self.subscribe_key=(subscribe_key) @subscribe_key = subscribe_key end def self.subscribe_key @subscribe_key end def self.secret_key=(secret_key) @secret_key = secret_key end def self.secret_key @secret_key end def self.connection @pubnub ||= ::Pubnub.new( publish_key: self.publish_key, # publish_key only required if publishing. subscribe_key: self.subscribe_key, # required secret_key: self.secret_key, error_callback: lambda { |msg| Rails.logger.error( msg.inspect )} ) end def self.publish(message) message.symbolize_keys! self.connection.publish( channel: message[:channel], message: message, http_sync: true, callback: lambda{|response| if 0 == JSON.parse(response.instance_variable_get(:@response)).first #pubnub publishing failed if attempts <= 3 self.publish!(message, attempts) #retry if we failed else Rails.logger.debug("ForeignOffice#publish! failed after #{attempts} attempts. message: #{message.inspect}") end end } ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreign_office-0.0.6 | lib/foreign_office/busses/pubnub_bus.rb |
foreign_office-0.0.5 | lib/foreign_office/busses/pubnub_bus.rb |