Sha256: 4542144acbf6ee04796e6d7fd318863359f3e4415542fe86f731a8f0e8527088

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

require 'curb'

module RankMirror
	class Speed
		def initialize(uri)
			@uri = uri
		end

		def get
			if RankMirror::Reachable.new(@uri,500).reachable?
				r = Curl::Easy.new(@uri)
				r.perform
				return r.download_speed / 1024.0
			else
				# usually in this case, the mirror is online but:
				# 1. has bad repodata. eg. not fully rsync the origin, or even empty. 
				# 2. volatile. sometimes at good speed, sometimes unreachable.
				# 3. too slow. takes more than 5 seconds to start a download.
				# not break here because we're about to find out the good mirrors, not the bad ones.
				return 0
			end
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rankmirror-1.1.0 lib/rankmirror/speed.rb