-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[paymentservice] add paymentServiceFailure & paymentServiceUnreachabl…
…e featureflags
- Loading branch information
Showing
7 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let grpc = require('@grpc/grpc-js'); | ||
let protoLoader = require('@grpc/proto-loader'); | ||
let protoDescriptor = grpc.loadPackageDefinition(protoLoader.loadSync('demo.proto')); | ||
let client = new protoDescriptor.oteldemo.FeatureFlagService ( | ||
process.env.FEATURE_FLAG_GRPC_SERVICE_ADDR, | ||
grpc.credentials.createInsecure() | ||
); | ||
|
||
module.exports.getFeatureFlagEnabled = async featureFlag => { | ||
try { | ||
const response = await new Promise((resolve, reject) => { | ||
client.getFlag({ name: featureFlag }, (error, response) => { | ||
error ? reject(error) : resolve(response); | ||
}); | ||
}); | ||
|
||
return response.flag?.enabled || false; | ||
} catch (error) { | ||
logger.error(`Error getting FeatureFlag: ${error}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters