Sha256: b1788bd62215ab23824f39ac0932d6d0606cdc1b7af77b0dd011fd13ba618c54

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 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 = SalesforceTopicManager.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.upsert_topics!
      @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(topic_data.transform_keys(&:to_sym))
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
salesforce_streamer-2.4.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.4.0.rc1 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.3.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.2.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.1.1 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.1.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.0.0 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.0.0.rc2 lib/salesforce_streamer/launcher.rb
salesforce_streamer-2.0.0.rc1 lib/salesforce_streamer/launcher.rb