Lessons Learned using Togglz
Table of Contents
Feature Toggles (a.k.a. Feature Flags{:target="_blank"}) is a very powerful pattern to test and introduce new features in a production environment. I started to experiment with Togglz as a OSS library to implement what I needed. While I used Spring-Boot to demostrate my use of Togglz, this can be done with any other framework.
For Spring-Boot, the documentation says all you need is to add the following:
{% highlight xml linenos %}
This is not completely true as the following error occurs:
{% highlight log %} [ERROR] contextLoads Time elapsed: 0 s «< ERROR! java.lang.NoClassDefFoundError: org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter {% endhighlight %}
It appears you need to use the following dependency:
{% highlight xml linenos %}
This makes the code to compile without problems. Of course, I also needed the console module, so I added:
{% highlight xml linenos %}
This allowed me to have a working app with features enabled/disabled (very quickly I may add). Next was unto setting up a feature flag. This was very easy with the following properties:
{% highlight properties linenos %} togglz.console.enabled=true togglz.console.path=/toggles togglz.console.secured=false togglz.console.use-management-port=false togglz.features.FAKE_JMS_LOAD.label=Fake JMS Load togglz.features.FAKE_JMS_LOAD.enabled=true {% endhighlight %}
Notice that I had to change the configuration to also not use the management port. This is described here.
A few things I would like to see in future distributions of Togglz:
- Given that Spring-Boot is simple to use, I think we should be able to have a way to add the owner of a given toggle. This is not possible with the existing API.
- In general, Togglz does not have a way to add more description to the flag. This seems like an essential feature, and I can see how much info can get lost.
In general, this seems like a good simple implementation of the “Feature Flag” pattern that provides a nice UI to non-technical folks to manage. It’s definitely a great start, but I can see having the need to have more features.