Sha256: dc88d867d419f8e3059c72f065419a45ef065004ba179a430ec5c8ceda4d6c62

Contents?: true

Size: 434 Bytes

Versions: 10

Compression:

Stored size: 434 Bytes

Contents

require 'murmurhash3'

module Unleash
  module Strategy
    module Util
      module_function

      NORMALIZER = 100
      VARIANT_NORMALIZER_SEED = 86_028_157

      # convert the two strings () into a number between 1 and base (100 by default)
      def get_normalized_number(identifier, group_id, seed, base = NORMALIZER)
        MurmurHash3::V32.str_hash("#{group_id}:#{identifier}", seed) % base + 1
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
unleash-5.1.1 lib/unleash/strategy/util.rb
unleash-5.1.0 lib/unleash/strategy/util.rb
unleash-5.0.7 lib/unleash/strategy/util.rb
unleash-5.0.6 lib/unleash/strategy/util.rb
unleash-5.0.5 lib/unleash/strategy/util.rb
unleash-5.0.4 lib/unleash/strategy/util.rb
unleash-5.0.3 lib/unleash/strategy/util.rb
unleash-5.0.2 lib/unleash/strategy/util.rb
unleash-5.0.1 lib/unleash/strategy/util.rb
unleash-5.0.0 lib/unleash/strategy/util.rb