Sha256: 7e7c43cad23ee82de27144831142ad5a7d115bc5f4844e7c9e3cda093e5a553f

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

module SalesforceStreamer
  # SalesforceStreamer::Launcher is the entry point for starting the Restforce
  # Streaming API server. It is responsible for upserting each PushTopic and
  # starting the server.
  class Launcher
    def initialize
      load_server_configuration
      @manager = TopicManager.new push_topics: @push_topics
      @server = Server.new push_topics: @push_topics
    end

    # Manages each PushTopic configured and starts the Streaming API listener.
    def run
      Log.info 'Launching Streamer Services'
      @manager.run
      @server.push_topics = @manager.push_topics
      @server.run
    end

    private

    def load_server_configuration
      require_application
      initialize_push_topics
    end

    def require_application
      return unless Configuration.instance.require_path

      Log.debug 'Loading the require path'
      require Configuration.instance.require_path
    end

    def initialize_push_topics
      Log.debug 'Loading and validating PushTopics configuration'
      @push_topics = []
      Configuration.instance.push_topic_data.each_value do |topic_data|
        Log.debug topic_data.to_s
        @push_topics << PushTopic.new(data: topic_data)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
salesforce_streamer-1.2.2 lib/salesforce_streamer/launcher.rb
salesforce_streamer-1.2.1 lib/salesforce_streamer/launcher.rb
salesforce_streamer-1.2.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-1.1.3 lib/salesforce_streamer/launcher.rb
salesforce_streamer-1.1.1 lib/salesforce_streamer/launcher.rb