Sha256: 769d0bc6cdb58b3473549c5c01a6ae3310b5584731b9558bca2d0e21f1012fbc

Contents?: true

Size: 1.33 KB

Versions: 21

Compression:

Stored size: 1.33 KB

Contents

module Mongo
  module ServerSelection
    module RTT

      # Represents a specification.
      #
      # @since 2.0.0
      class Spec

        # @return [ String ] description The spec description.
        attr_reader :description

        # @return [ Float ] average_rtt The starting average round trip time, in seconds.
        attr_reader :average_rtt

        # @return [ Float ] new_rtt The new round trip time for ismaster, in seconds.
        attr_reader :new_rtt

        # @return [ Float ] new_average_rtt The newly calculated moving average round trip time, in seconds.
        attr_reader :new_average_rtt

        # Instantiate the new spec.
        #
        # @example Create the spec.
        #   Spec.new(file)
        #
        # @param [ String ] file The name of the file.
        #
        # @since 2.0.0
        def initialize(file)
          @test = YAML.load(ERB.new(File.new(file).read).result)
          @description = "#{File.basename(file)}: avg_rtt_ms: #{@test['avg_rtt_ms']}, new_rtt_ms: #{@test['new_rtt_ms']}," +
                           " new_avg_rtt: #{@test['new_avg_rtt']}"
          @average_rtt = @test['avg_rtt_ms'] == 'NULL' ? nil : @test['avg_rtt_ms'].to_f / 1000
          @new_rtt = @test['new_rtt_ms'].to_f / 1000
          @new_average_rtt = @test['new_avg_rtt'].to_f / 1000
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/support/server_selection_rtt.rb
mongo-2.10.5 spec/support/server_selection_rtt.rb
mongo-2.10.4 spec/support/server_selection_rtt.rb
mongo-2.10.3 spec/support/server_selection_rtt.rb
mongo-2.9.2 spec/support/server_selection_rtt.rb
mongo-2.10.2 spec/support/server_selection_rtt.rb
mongo-2.11.0.rc0 spec/support/server_selection_rtt.rb
mongo-2.10.1 spec/support/server_selection_rtt.rb
mongo-2.10.0 spec/support/server_selection_rtt.rb
mongo-2.9.1 spec/support/server_selection_rtt.rb
mongo-2.10.0.rc0 spec/support/server_selection_rtt.rb
mongo-2.9.1.rc0 spec/support/server_selection_rtt.rb
mongo-2.9.0 spec/support/server_selection_rtt.rb
mongo-2.9.0.rc1 spec/support/server_selection_rtt.rb
mongo-2.9.0.rc0 spec/support/server_selection_rtt.rb
mongo-2.8.0 spec/support/server_selection_rtt.rb
mongo-2.7.2 spec/support/server_selection_rtt.rb
mongo-2.8.0.rc0 spec/support/server_selection_rtt.rb
mongo-2.7.1 spec/support/server_selection_rtt.rb
mongo-2.7.0 spec/support/server_selection_rtt.rb