Monday, December 2, 2019

Lessons Learned using Togglz

Feature Toggles (a.k.a. Feature Flags) are a common way to test new features in a production environment. I started to experiment with Togglz as a OSS library to implement what I needed. For the purpose of my description, I used Spring Boot as it makes apps development simpler. Here are my findings:

First, the documentation says all you need is to add the following:
  
 <dependency>
  <groupid>org.togglz</groupid>
  <artifactid>togglz-spring-boot-starter</artifactid>
  <version>2.6.1.Final</version>
 </dependency>
  
This is not completely true as the following error occurs:

[ERROR] contextLoads  Time elapsed: 0 s  <<< ERROR!
java.lang.NoClassDefFoundError: 
org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter

It appears you need to use the following dependency:
  
 <dependency>
  <groupid>org.springframework.boot</groupid>
  <artifactid>spring-boot-starter-web</artifactid>
 </dependency>
This makes the code compile without problems. Of course, I also need the console module, so I added:
  
 <dependency>
  <groupid>org.togglz</groupid>
  <artifactid>togglz-console</artifactid>
  <version>2.6.1.Final</version>
 </dependency>
  
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:
 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

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:

  1. Given that Spring Boot is simple to use, I think we should be able to also add a way to add the Owner of a given toggle. This is not possible with the entries. 
  2. In general, Togglz does not have a way to add more description to the flag. This would be super interesting as many features toggles 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. 



No comments: