2023-03-20 09:09:35
Feature Toggle Pattern Should:
Default to safe . So if the configuration is missing, the feature defaults to the safer of the two options.- Have a value that is
easily accessible , within aconfiguration file .- At runtime we should be able to change the value in the configuration file.
- Deployment tools can access the value in the configuration file so that test can have a different value to production. Therefore there is no need to have a different batch in source control.
Example
An example of the Feature Toggle Pattern implemented within the Startup class of Monolith Application. This example also shows the
var useCustomerManagerAPI = Configuration.GetValue_a_m_p_;_lt;bool_a_m_p_;_gt;("UseCustomerManagerAPI"); if (useCustomerManagerAPI) { services.AddSingleton_a_m_p_;_lt;IBankAccountRepository, BankAccountRepositoryService_a_m_p_;_gt; (); services.AddSingleton_a_m_p_;_lt;ICustomerRepository, CustomerRepositoryService_a_m_p_;_gt; (); } else { services.AddSingleton_a_m_p_;_lt;IBankAccountRepository, BankAccountRepository_a_m_p_;_gt; (); services.AddSingleton_a_m_p_;_lt;ICustomerRepository, CustomerRepository_a_m_p_;_gt; (); }