Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[featureflag] expose feature flag API via frontend #1

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ services:
- CART_SERVICE_ADDR
- CHECKOUT_SERVICE_ADDR
- CURRENCY_SERVICE_ADDR
- FEATURE_FLAG_GRPC_SERVICE_ADDR
- PRODUCT_CATALOG_SERVICE_ADDR
- RECOMMENDATION_SERVICE_ADDR
- SHIPPING_SERVICE_ADDR
Expand Down
24 changes: 15 additions & 9 deletions pb/demo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -266,46 +266,52 @@ message Ad {
service FeatureFlagService {
rpc GetFlag(GetFlagRequest) returns (GetFlagResponse) {}
rpc CreateFlag(CreateFlagRequest) returns (CreateFlagResponse) {}
rpc UpdateFlag(UpdateFlagRequest) returns (UpdateFlagResponse) {}
rpc UpdateFlagProbability(UpdateFlagProbabilityRequest) returns (UpdateFlagProbabilityResponse) {}
rpc ListFlags(ListFlagsRequest) returns (ListFlagsResponse) {}
rpc DeleteFlag(DeleteFlagRequest) returns (DeleteFlagResponse) {}
}

message Flag {
message FlagEvaluationResult {
string name = 1;
string description = 2;
bool enabled = 3;
}

message FlagDefinition {
string name = 1;
string description = 2;
float enabled = 3;
}

message GetFlagRequest {
string name = 1;
}

message GetFlagResponse {
Flag flag = 1;
FlagEvaluationResult flag = 1;
}

message CreateFlagRequest {
string name = 1;
string description = 2;
bool enabled = 3;
float enabled = 3;
}

message CreateFlagResponse {
Flag flag = 1;
FlagDefinition flag = 1;
}

message UpdateFlagRequest {
message UpdateFlagProbabilityRequest {
string name = 1;
bool enabled = 2;
float enabled = 2;
}

message UpdateFlagResponse {}
message UpdateFlagProbabilityResponse {}

message ListFlagsRequest {}

message ListFlagsResponse {
repeated Flag flag = 1;
repeated FlagDefinition flag = 1;
}

message DeleteFlagRequest {
Expand Down
92 changes: 92 additions & 0 deletions regenerate-grpc-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/sh

set -euo pipefail

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# This script is used to update generated code after changing demo.proto.

cd -P -- "$(dirname -- "$0")"
pwd

command -v npm >/dev/null 2>&1 || {
cat <<EOF >&2
npm needs to be installed but it isn't.

Aborting.
EOF
exit 1
}

command -v go >/dev/null 2>&1 || {
cat <<EOF >&2
go needs to be installed but it isn't.

Aborting.
EOF
exit 1
}

command -v rebar3 >/dev/null 2>&1 || {
cat <<EOF >&2
rebar3 needs to be installed but it isn't.

Aborting.
EOF
exit 1
}


command -v protoc >/dev/null 2>&1 || {
cat <<EOF >&2
protoc needs to be installed but it isn't.

Aborting.
EOF
exit 1
}

echo "Regenerating typescript code in src/frontend based on demo.proto"
pushd src/frontend > /dev/null
# The npm script grpc:generate expects the pb directory to be available in the current directory (src/frontend) because it is
# intended to be used during Docker build, where pb is copied to the same working directory as src/frontend. To get around that
# difference, we temporarily create a symlink to pb and then remove it after the script is done.
ln -s ../../pb pb
npm run grpc:generate
rm pb
popd > /dev/null

echo "Regenerating Go code in src/accountingservice based on demo.proto"
pushd src/accountingservice > /dev/null
go generate
popd > /dev/null

echo "Regenerating Go code in src/checkoutservice based on demo.proto"
pushd src/checkoutservice > /dev/null
go generate
popd > /dev/null

echo "Regenerating Go code in src/productcatalogservice based on demo.proto"
pushd src/productcatalogservice > /dev/null
go generate
popd > /dev/null

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

echo "Recompiling Erlang code in src/featureflagservice based on demo.proto"
pushd src/featureflagservice > /dev/null
# The Erlang build expects the proto file to be available in src/featureflagservice/proto) because it is
# intended to be used during Docker build, where demo.proto is copied to the the proto directory in the same working directory
# as the Erlang source code. To get around that difference, we temporarily create a symlink to ../../pb as proto and then remove
# it after the script is done.
ln -s ../../pb proto
rebar3 grpc_regen
rm proto
popd > /dev/null


echo done
3 changes: 3 additions & 0 deletions restart-service.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh

set -euo pipefail

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

Expand Down
Loading