Sha256: ec5c1eaeffad72c6ccff4c01e9470dacae9f37dd3a72bd57da55c721713c9c20

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

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
      if Configuration.instance.require_path
        Log.debug 'Loading the require path'
        require Configuration.instance.require_path
      end
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
salesforce_streamer-0.3.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-0.2.3 lib/salesforce_streamer/launcher.rb
salesforce_streamer-0.2.2 lib/salesforce_streamer/launcher.rb
salesforce_streamer-0.2.1 lib/salesforce_streamer/launcher.rb