0
0
Microservicessystem_design~10 mins

Feature flags in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if a feature is enabled before executing it.

Microservices
if feature_flags.is_enabled([1]):
    execute_new_feature()
Drag options to blanks, or click blank then click option'
ATrue
Bnew_ui
Cfeature_name
D"new_ui"
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the feature flag name without quotes causing a NameError.
Passing a boolean value instead of the feature flag name.
2fill in blank
medium

Complete the code to fetch the feature flag status from the config service.

Microservices
status = config_service.get_flag_status([1])
Drag options to blanks, or click blank then click option'
A"beta_feature"
Bfeature_id
CTrue
Dflag_status
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable name instead of a string literal.
Using boolean values instead of flag names.
3fill in blank
hard

Fix the error in the code that updates a feature flag status.

Microservices
feature_flags.update_flag([1], True)
Drag options to blanks, or click blank then click option'
A123
B"new_feature"
CTrue
Dflag_enabled
Attempts:
3 left
💡 Hint
Common Mistakes
Passing an integer instead of a string as the flag name.
Passing a boolean instead of the flag name.
4fill in blank
hard

Fill both blanks to create a dictionary of feature flags with their enabled status.

Microservices
flags = [1](flag: feature_flags.[2](flag) for flag in all_flags)
Drag options to blanks, or click blank then click option'
Adict
Bis_enabled
Clist
Dget_status
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict causing wrong data structure.
Using a wrong method name to check flag status.
5fill in blank
hard

Fill all three blanks to filter enabled features and store their names in a list.

Microservices
enabled_features = [flag for flag in all_flags if feature_flags.[1](flag) [2] [3]]
Drag options to blanks, or click blank then click option'
Ais_enabled
B==
CTrue
Dget_flag
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment = instead of comparison ==.
Comparing with False instead of True.