Class TargetingFilter
java.lang.Object
com.azure.spring.cloud.feature.management.filters.TargetingFilter
- All Implemented Interfaces:
FeatureFilter
`Microsoft.TargetingFilter` enables evaluating a user/group/overall rollout of a feature.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringAudience in the filterprotected final TargetingContextAccessorAccessor for identifying the current user/group when evaluatingprotected static final StringAudience that always returns falseprotected static final Stringgroups field in the filterprotected static final ObjectMapperObject Mapper for converting configurations to featuresprotected final TargetingEvaluationOptionsOptions for evaluating the filterprotected static final StringError message for when the total Audience value is greater than 100 percent.protected static final Stringusers field in the filter -
Constructor Summary
ConstructorsConstructorDescriptionTargetingFilter(TargetingContextAccessor contextAccessor) Filter for targeting a user/group/percentage of users.TargetingFilter(TargetingContextAccessor contextAccessor, TargetingEvaluationOptions options) `Microsoft.TargetingFilter` evaluates a user/group/overall rollout of a feature. -
Method Summary
Modifier and TypeMethodDescriptionbooleanevaluate(FeatureFilterEvaluationContext context) Evaluates if the filter is on or off.protected doubleisTargetedPercentage(String contextId) Computes the percentage that the contextId falls into.
-
Field Details
-
USERS
users field in the filter- See Also:
-
GROUPS
groups field in the filter- See Also:
-
AUDIENCE
Audience in the filter- See Also:
-
EXCLUSION
Audience that always returns false- See Also:
-
OUT_OF_RANGE
Error message for when the total Audience value is greater than 100 percent.- See Also:
-
OBJECT_MAPPER
Object Mapper for converting configurations to features -
contextAccessor
Accessor for identifying the current user/group when evaluating -
options
Options for evaluating the filter
-
-
Constructor Details
-
TargetingFilter
Filter for targeting a user/group/percentage of users.- Parameters:
contextAccessor- Accessor for identifying the current user/group when evaluating
-
TargetingFilter
public TargetingFilter(TargetingContextAccessor contextAccessor, TargetingEvaluationOptions options) `Microsoft.TargetingFilter` evaluates a user/group/overall rollout of a feature.- Parameters:
contextAccessor- Context for evaluating the users/groups.options- enables customization of the filter.
-
-
Method Details
-
evaluate
Description copied from interface:FeatureFilterEvaluates if the filter is on or off. Returning true results in Feature evaluation ending and returning true. Returning false results in the next Feature evaluation to continue.- Specified by:
evaluatein interfaceFeatureFilter- Parameters:
context- The context for whether or not the filter is passed.- Returns:
- True if the feature is enabled, false otherwise.
-
isTargetedPercentage
Computes the percentage that the contextId falls into.- Parameters:
contextId- Id of the context being targeted- Returns:
- the bucket value of the context id
- Throws:
TargetingException- Unable to create hash of target context
-