File: util.rb

package info (click to toggle)
ruby-unleash 3.2.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: ruby: 1,098; makefile: 10; sh: 4
file content (16 lines) | stat: -rw-r--r-- 379 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'murmurhash3'

module Unleash
  module Strategy
    module Util
      module_function

      NORMALIZER = 100

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