Ejemplo n.º 1
0
        internal EvaluationDetail <JToken> GetValueForVariationOrRollout(VariationOrRollout vr,
                                                                         User user, EvaluationReason reason)
        {
            var index = vr.VariationIndexForUser(user, Key, Salt);

            if (index == null)
            {
                Log.ErrorFormat("Data inconsistency in feature flag \"{0}\": variation/rollout object with no variation or rollout", Key);
                return(ErrorResult(EvaluationErrorKind.MALFORMED_FLAG));
            }
            return(GetVariation(index.Value, reason));
        }
Ejemplo n.º 2
0
 internal FeatureFlag(string key, int version, bool on, List <Prerequisite> prerequisites, string salt,
                      List <Target> targets, List <Rule> rules, VariationOrRollout fallthrough, int?offVariation,
                      List <JToken> variations,
                      bool deleted)
 {
     Key           = key;
     Version       = version;
     On            = on;
     Prerequisites = prerequisites;
     Salt          = salt;
     Targets       = targets;
     Rules         = rules;
     Fallthrough   = fallthrough;
     OffVariation  = offVariation;
     Variations    = variations;
     Deleted       = deleted;
 }
Ejemplo n.º 3
0
 internal FeatureFlag(string key, int version, bool on, List <Prerequisite> prerequisites, string salt,
                      List <Target> targets, List <Rule> rules, VariationOrRollout fallthrough, int?offVariation,
                      List <JToken> variations, bool trackEvents, long?debugEventsUntilDate,
                      bool deleted, bool clientSide)
 {
     Key                  = key;
     Version              = version;
     On                   = on;
     Prerequisites        = prerequisites;
     Salt                 = salt;
     Targets              = targets;
     Rules                = rules;
     Fallthrough          = fallthrough;
     OffVariation         = offVariation;
     Variations           = variations;
     TrackEvents          = trackEvents;
     DebugEventsUntilDate = debugEventsUntilDate;
     Deleted              = deleted;
     ClientSide           = clientSide;
 }
Ejemplo n.º 4
0
        public bool MatchesUser(User user, string segmentKey, string salt)
        {
            foreach (var c in Clauses)
            {
                if (!c.MatchesUserNoSegments(user))
                {
                    return(false);
                }
            }

            // If the Weight is absent, this rule matches
            if (!Weight.HasValue)
            {
                return(true);
            }

            // All of the clauses are met. See if the user buckets in
            String by     = (BucketBy == null) ? "key" : BucketBy;
            double bucket = VariationOrRollout.BucketUser(user, segmentKey, by, salt);
            double weight = (double)this.Weight / 100000F;

            return(bucket < weight);
        }