Skip to content

Commit

Permalink
[paymentservice] support range feature flag for simulated slowness
Browse files Browse the repository at this point in the history
This also adds support for range feature flags in the feature flag
service and its API.
  • Loading branch information
basti1302 committed Jan 31, 2024
1 parent d76ea82 commit 937ae70
Show file tree
Hide file tree
Showing 16 changed files with 1,542 additions and 707 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ services:
- OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=paymentservice
- FEATURE_FLAG_GRPC_SERVICE_ADDR
depends_on:
otelcol:
condition: service_started
Expand Down
24 changes: 24 additions & 0 deletions pb/demo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ service FeatureFlagService {
*/
rpc EvaluateProbabilityFeatureFlag(EvaluateProbabilityFeatureFlagRequest) returns (EvaluateProbabilityFeatureFlagResponse) {}

/*
* A convenience function to fetch a triplet of feature flag values that represent a range of values. For example, for
* simulating increased request latencies in a service, the triplet of feature flags to be created would be
* - serviceNameSimulateSlowness: on/off switch or probability for the feature (value is >= 0 & <= 1),
* - serviceNameSimulateSlownessLowerBound: the lower bound in milliseconds for the additional delay,
* - serviceNameSimulateSlownessUpperBound: the upper bound in milliseconds for the additional delay.
* That is, the feature flag API assumes that there are additional feature flag values with the suffix "LowerBound" and
* "UpperBound" when a range feature flag with a particular name is requested. In case the feature is enabled, but one or both
* of lower/upper bound does not exist, the arbitrary defaults for the lower and upper bound are 0 and 1000 respectively.
*/
rpc GetRangeFeatureFlag(RangeFeatureFlagRequest) returns (RangeFeatureFlagResponse) {}

/* Creates a new feature flag. */
rpc CreateFlag(CreateFlagRequest) returns (CreateFlagResponse) {}

Expand Down Expand Up @@ -303,6 +315,18 @@ message EvaluateProbabilityFeatureFlagResponse {
bool enabled = 1;
}

message RangeFeatureFlagRequest {
string name = 1;
string nameLowerBound = 2;
string nameUpperBound = 3;
}

message RangeFeatureFlagResponse {
bool enabled = 1;
float lowerBound = 2;
float upperBound = 3;
}

message GetFeatureFlagValueRequest {
string name = 1;
}
Expand Down
5 changes: 2 additions & 3 deletions regenerate-grpc-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ EOF
exit 1
}


command -v protoc >/dev/null 2>&1 || {
cat <<EOF >&2
protoc needs to be installed but it isn't.
Expand Down Expand Up @@ -74,7 +73,7 @@ popd > /dev/null

echo "Regenerating Java code in src/adservice based on demo.proto"
pushd src/adservice > /dev/null
./gradlew generateProto
./gradlew generateProto
popd > /dev/null

echo "Recompiling Erlang code in src/featureflagservice based on demo.proto"
Expand All @@ -89,4 +88,4 @@ rm proto
popd > /dev/null


echo done
echo done
Loading

0 comments on commit 937ae70

Please sign in to comment.