lib/dynflow/world/invalidation.rb
# Checks if all worlds are valid and optionally invalidates them
#
# @param auto_invalidate [Boolean] whether automatic invalidation should be performed
# @param worlds_filter [Hash] hash of filters to select only matching worlds
# @return [Hash{String=>Symbol}] hash containg validation results, mapping world id to a result
Checks if all worlds are valid and optionally invalidates them
Checks if all worlds are valid and optionally invalidates them
def worlds_validity_check(auto_invalidate = true, worlds_filter = {})
        worlds = coordinator.find_worlds(false, worlds_filter)
        world_checks = worlds.reduce({}) do |hash, world|
          hash.update(world => ping_without_cache(world.id, self.validity_check_timeout))
        end
        world_checks.values.each(&:wait)
        results = {}
        world_checks.each do |world, check|
          if check.fulfilled?
            result = :valid
          else
            if auto_invalidate
              begin
                invalidate(world)
                result = :invalidated
              rescue => e
                logger.error e
                result = e.message
              end
            else
              result = :invalid
            end
          end
          results[world.id] = result
        end
        unless results.values.all? { |result| result == :valid }
          logger.error "invalid worlds found #{results.inspect}"
        end
        return results
      end
def worlds_validity_check ( auto_invalidate = true , worlds_filter = { } ) worlds = coordinator . find_worlds ( false , worlds_filter ) world_checks = worlds . reduce ( { } ) do | hash , world | hash . update ( world => ping_without_cache ( world . id , self . validity_check_timeout ) ) end world_checks . values . each ( & :wait ) results = { } world_checks . each do | world , check | if check . fulfilled? result = :valid else if auto_invalidate begin invalidate ( world ) result = :invalidated rescue => e logger . error e result = e . message end else result = :invalid end end results [ world . id ] = result end unless results . values . all? { | result | result == :valid } logger . error "invalid worlds found #{results.inspect}" end return results end
Checks if all worlds are valid and optionally invalidates them
Checks if all worlds are valid and optionally invalidates them
hash containg validation results, mapping world id to a result
hash containg validation results mapping world id to a result
Hash{String=>Symbol}
auto_invalidate
whether automatic invalidation should be performed
whether automatic invalidation should be performed
worlds_filter
hash of filters to select only matching worlds
hash of filters to select only matching worlds