Sha256: 2b3961cb5bde77eb3c4f9b835995295605a2bf2f0a1494aa8146a7d7d4a81009
Contents?: true
Size: 740 Bytes
Versions: 4
Compression:
Stored size: 740 Bytes
Contents
# frozen_string_literal: true module Traxor module Rack module Middleware module QueueTime X_REQUEST_START = 'HTTP_X_REQUEST_START' # any timestamps before this are thrown out and the parser # will try again with a larger unit (2000/1/1 UTC) EARLIEST_ACCEPTABLE_TIME = Time.at(946_684_800).utc DIVISORS = [1_000_000, 1_000, 1].freeze def self.parse(env) return unless env[X_REQUEST_START] value = env[X_REQUEST_START].to_s.sub(/t=/, '') DIVISORS.each do |divisor| time = Time.at(value.to_f / divisor).utc return time if time > EARLIEST_ACCEPTABLE_TIME end nil end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems