Sha256: 205a93063d0a708d750b773636404c9079af0f8342e4ac640990469ddb4e4527
Contents?: true
Size: 973 Bytes
Versions: 5
Compression:
Stored size: 973 Bytes
Contents
module SalesforceStreamer class Server attr_writer :push_topics def initialize(push_topics: []) @push_topics = push_topics end def run Log.info 'Starting Server' catch_signals start_em end private def catch_signals %w[INT USR1 USR2 TERM TTIN TSTP].each do |sig| trap sig do puts "Caught signal #{sig}. Shutting down..." exit 0 end end end def client return @client if @client @client = Restforce.new @client.authenticate! @client.faye.add_extension ReplayIdErrorExtension.new @client end def start_em EM.run do @push_topics.map do |topic| client.subscribe topic.name, replay: topic.replay.to_i do |msg| Log.info "Message received from topic #{topic.name}" MessageReceiver.call topic.name, topic.handler_constant, msg end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems