From a4a9d47093bb0dc4d676a518e645cfc8301a20c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Tue, 17 Jan 2023 22:00:15 +0100 Subject: [PATCH] fix: flexible-rollout random stickiness is not random enough It's easy to get skew when we only pick numbers between 0 and 100. --- src/strategy/flexible-rollout-strategy.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/strategy/flexible-rollout-strategy.ts b/src/strategy/flexible-rollout-strategy.ts index 46caf1e1..cb0e3b22 100644 --- a/src/strategy/flexible-rollout-strategy.ts +++ b/src/strategy/flexible-rollout-strategy.ts @@ -9,12 +9,12 @@ const STICKINESS = { }; export default class FlexibleRolloutStrategy extends Strategy { - private randomGenerator: Function = () => `${Math.round(Math.random() * 100) + 1}`; + private randomGenerator: Function = () => `${Math.round(Math.random() * 10000) + 1}`; - constructor(radnomGenerator?: Function) { + constructor(randomGenerator?: Function) { super('flexibleRollout'); - if (radnomGenerator) { - this.randomGenerator = radnomGenerator; + if (randomGenerator) { + this.randomGenerator = randomGenerator; } }