Bird
0
0

Which of the following code snippets correctly implements a feature toggle to route requests during an incremental migration?

easy📝 Conceptual Q3 of 15
Microservices - Migration from Monolith
Which of the following code snippets correctly implements a feature toggle to route requests during an incremental migration?
Aif (user.isAdmin) { routeToOldService(); } else { routeToNewService(); }
Bif (featureToggle.isEnabled('newService')) { routeToNewService(); } else { routeToOldService(); }
CrouteToNewService(); // no toggle check
Dif (featureToggle.isDisabled('newService')) { routeToNewService(); } else { routeToOldService(); }
Step-by-Step Solution
Solution:
  1. Step 1: Understand feature toggles

    Feature toggles enable conditional routing based on configuration flags.
  2. Step 2: Analyze options

    if (featureToggle.isEnabled('newService')) { routeToNewService(); } else { routeToOldService(); } correctly checks if the feature toggle is enabled to route traffic accordingly.
  3. Final Answer:

    if (featureToggle.isEnabled('newService')) { routeToNewService(); } else { routeToOldService(); } -> Option B
  4. Quick Check:

    Toggle enabled routes to new service [OK]
Quick Trick: Check toggle enabled before routing [OK]
Common Mistakes:
  • Routing without toggle check
  • Using incorrect toggle logic
  • Routing based on unrelated user attributes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes