Sha256: c914d7c9c6414ef4a8a5128037fa950b60a9f9fffeee8c0bca443baa31c28c10

Contents?: true

Size: 1.88 KB

Versions: 10

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true
# Maintain a cache of failure data for scenario runs
module QaServer
  class ScenarioRunFailuresCache
    class_attribute :scenario_history_class
    self.scenario_history_class = QaServer::ScenarioRunHistory

    class << self
      include QaServer::CacheKeys

      # Set of failures for a run
      # @param run [QaServer::ScenarioRunRegistry]
      # @returns [Array<Hash>] details for any failing scenarios in the run
      # @example
      #   [ { status: :bad,
      #       authority_name: "geonames_ld4l_cache",
      #       subauthority_name: "area",
      #       service: "ld4l_cache",
      #       action: "search",
      #       url: "/qa/search/linked_data/geonames_ld4l_cache/area?q=France&maxRecords=4",
      #       err_message: "Unable to connect to authority",
      #       scenario_type: :connection
      #       run_time: 11.2 },
      #     { status: :unknown,
      #       authority_name: "oclcfast_ld4l_cache",
      #       subauthority_name: "Person",
      #       service: "ld4l_cache",
      #       action: "search",
      #       url: "/qa/search/linked_data/oclcfast_ld4l_cache/person?q=mark twain&maxRecords=4",
      #       err_message: "Not enough search results returned",
      #       scenario_type: :connection
      #       run_time: 0.123 } ]
      def failures_for_run(run:)
        Rails.cache.fetch(cache_key_for_run_failures(run.id), expires_in: next_expiry, race_condition_ttl: 30.seconds) do
          QaServer.config.monitor_logger.debug("(QaServer::ScenarioRunFailuresCache) - CALCULATING FAILURES for scenario run #{run.id}")
          scenario_history_class.run_failures(run_id: run.id)
        end
      end

    private

      def cache_key_for_run_failures(id)
        "#{SCENARIO_RUN_FAILURE_DATA_CACHE_KEY}--#{id}{"
      end

      def next_expiry
        QaServer::CacheExpiryService.cache_expiry
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
qa_server-8.0.1 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.9.2 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.9.1 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.9.0 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.8.0 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.7.1 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.7.0 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.6.0 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.5.1 app/cache_processors/qa_server/scenario_run_failures_cache.rb
qa_server-7.5.0 app/cache_processors/qa_server/scenario_run_failures_cache.rb