Sha256: 24553aa038ed04a3863aa3147afbe04e8a9a74df4174c7a0bdda33ae35729e74

Contents?: true

Size: 817 Bytes

Versions: 11

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module Core
    # Namespace for some small utilities used across the ecosystem
    module Helpers
      # Time related methods used across Karafka
      module Time
        if RUBY_VERSION >= '3.2'
          # @return [Float] current monotonic time in milliseconds
          def monotonic_now
            ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :float_millisecond)
          end
        else
          # @return [Float] current monotonic time in milliseconds
          def monotonic_now
            ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) * 1_000
          end
        end

        # @return [Float] current time in float
        def float_now
          ::Process.clock_gettime(::Process::CLOCK_REALTIME)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
karafka-core-2.4.10 lib/karafka/core/helpers/time.rb
karafka-core-2.4.9 lib/karafka/core/helpers/time.rb
karafka-core-2.4.8 lib/karafka/core/helpers/time.rb
karafka-core-2.4.7 lib/karafka/core/helpers/time.rb
karafka-core-2.4.6 lib/karafka/core/helpers/time.rb
karafka-core-2.4.5 lib/karafka/core/helpers/time.rb
karafka-core-2.4.4 lib/karafka/core/helpers/time.rb
karafka-core-2.4.3 lib/karafka/core/helpers/time.rb
karafka-core-2.4.2 lib/karafka/core/helpers/time.rb
karafka-core-2.4.1 lib/karafka/core/helpers/time.rb
karafka-core-2.4.1.rc1 lib/karafka/core/helpers/time.rb