Sha256: 59aaa4664cd20728cabf4f55e14f3bd15eaf14089e2c4537a952ae2f3d42611b
Contents?: true
Size: 875 Bytes
Versions: 4
Compression:
Stored size: 875 Bytes
Contents
# frozen_string_literal: true module SalesforceStreamer class Server attr_writer :push_topics def initialize(push_topics: []) @push_topics = push_topics @client = Restforce.new end def run @client.authenticate! 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 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
4 entries across 4 versions & 1 rubygems