All Projects → Feature-Flip → Flips

Feature-Flip / Flips

Repository for feature flip library which provides various annotations to flip any feature. Works with Java8, Spring, Spring Boot

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Flips

Springboot Starterkit
Starter Kit for Spring Boot based (REST APIs and WebMVC) micro services.
Stars: ✭ 596 (+1141.67%)
Mutual labels:  spring-boot, spring-mvc
Spring Streaming
SPA on Spring Boot 1.x, WebSockets and React, gradle, nodejs, spring-boot, gradle multi project, spring-mvc, spring-data, gradle dependency update plugin, react-router
Stars: ✭ 6 (-87.5%)
Mutual labels:  spring-boot, spring-mvc
Apollo
Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
Stars: ✭ 26,052 (+54175%)
Mutual labels:  spring-boot, spring-mvc
Watchdog Framework
🍻 「停止维护」基于SpringBoot+Shiro+Mybatis等开发的轻量级管理系统快速开发脚手架
Stars: ✭ 421 (+777.08%)
Mutual labels:  spring-boot, spring-mvc
Versioning Spring Boot Starter
Spring boot starter using for versioning rest easily.
Stars: ✭ 11 (-77.08%)
Mutual labels:  spring-boot, spring-mvc
Spring Lemon
Helper library for Spring Boot web applications
Stars: ✭ 529 (+1002.08%)
Mutual labels:  spring-boot, spring-mvc
Javaquarkbbs
基于Spring Boot实现的一个简易的Java社区
Stars: ✭ 755 (+1472.92%)
Mutual labels:  spring-boot, spring-mvc
Spring Boot File Upload Download Rest Api Example
Spring Boot File Upload / Download Rest API Example
Stars: ✭ 300 (+525%)
Mutual labels:  spring-boot, spring-mvc
Springbootunity
rabbitmq、redis、scheduled、socket、mongodb、Swagger2、spring data jpa、Thymeleaf、freemarker etc. (muti module spring boot project) (with spring boot framework,different bussiness scence with different technology。)
Stars: ✭ 845 (+1660.42%)
Mutual labels:  spring-boot, spring-mvc
Httpdoc
基于Java标准doc注释构建的代码零侵入的HTTP RESTful API在线测试,文档阅览以及SDK导出框架,支持Spring-Boot和Spring-MVC
Stars: ✭ 23 (-52.08%)
Mutual labels:  spring-boot, spring-mvc
Spring Boot Demo
spring boot demo 是一个Spring Boot、Spring Cloud的项目示例,根据市场主流的后端技术,共集成了30+个demo,未来将持续更新。该项目包含helloworld(快速入门)、web(ssh项目快速搭建)、aop(切面编程)、data-redis(redis缓存)、quartz(集群任务实现)、shiro(权限管理)、oauth2(四种认证模式)、shign(接口参数防篡改重放)、encoder(用户密码设计)、actuator(服务监控)、cloud-config(配置中心)、cloud-gateway(服务网关)等模块
Stars: ✭ 323 (+572.92%)
Mutual labels:  spring-boot, spring-mvc
Cloud Enabled Microservice
Tasks microservice (Spring Boot, MVC, Data, Lombok, Cloud, OAuth2, Config, Eureka, Zuul, Hystrix, Docker)
Stars: ✭ 14 (-70.83%)
Mutual labels:  spring-boot, spring-mvc
Efo
EFO是一个基于SpringBoot和Vue构建的文件分享系统,包括文件的上传与下载,文件的权限管理,远程文件管理等功能。
Stars: ✭ 327 (+581.25%)
Mutual labels:  spring-boot, spring-mvc
Heart First Javaweb
一个走心的 Java Web 入门开发教程
Stars: ✭ 561 (+1068.75%)
Mutual labels:  spring-boot, spring-mvc
Angularjs Springmvc Sample Boot
A RESTful sample using Spring Boot, Spring MVC, Spring Data and Angular/Bootstrap.
Stars: ✭ 309 (+543.75%)
Mutual labels:  spring-boot, spring-mvc
Mini Spring
mini-spring是简化版的spring框架,能帮助你快速熟悉spring源码和掌握spring的核心原理。抽取了spring的核心逻辑,代码极度简化,保留spring的核心功能,如IoC和AOP、资源加载器、事件监听器、类型转换、容器扩展点、bean生命周期和作用域、应用上下文等核心功能。
Stars: ✭ 698 (+1354.17%)
Mutual labels:  spring-boot, spring-mvc
Velocity Spring Boot Project
A Spring Boot Starter for velocity including Spring's official and Alibaba's implementation , e.g, Layout , Tools supports.
Stars: ✭ 285 (+493.75%)
Mutual labels:  spring-boot, spring-mvc
Angularjs Springmvc Sample
A RESTful sample using AnguarJS/Bootstrap as frontend and Spring MVC as REST API producer
Stars: ✭ 292 (+508.33%)
Mutual labels:  spring-boot, spring-mvc
Journaldev
JournalDev Projects
Stars: ✭ 897 (+1768.75%)
Mutual labels:  spring-boot, spring-mvc
Spring Mvc Thymeleaf Crud
Spring MVC CRUD Application with Thymeleaf, HTML5, CSS3 and Bootstrap
Stars: ✭ 14 (-70.83%)
Mutual labels:  spring-boot, spring-mvc

Flips

Flips is an implementation of Feature Toggles pattern for Java. Feature Toggles are a powerful technique, allowing teams to modify system behavior without changing the code.

Build Status Coverage Status

Getting Started

Following feature toggle is going to switch bean with same signature method to go live on specific date time. Property allows to define different datetime specific to ENV and in ISO 8601 format.

@Component
class MyBean {

    @FlipBean(with = AnotherBean.class)
    @FlipOnDateTime(cutoffDateTimeProperty="datetime-property")
    public List<Article> getLatestArticles(){
        // OLD logic of getting latest articles
    }
}

@Component
class AnotherBean {

    public List<Article> getLatestArticles(){
      // NEW logic of getting latest articles
    }
}

Why another library for feature toggle ?

The idea behind Flips is to let the users implement toggles with minimum configuration and coding. This library is intended to work with Java8, Spring Core / Spring MVC / Spring Boot.

Where do I get sample project(s) ?

Sample projects can be found here.

Maven Configuration

Include flips-web if the project is a WEB project -

  <dependency>
    <groupId>com.github.feature-flip</groupId>
    <artifactId>flips-web</artifactId>
    <version>1.0.1</version>
  </dependency>

Otherwise flips-core,

  <dependency>
    <groupId>com.github.feature-flip</groupId>
    <artifactId>flips-core</artifactId>
    <version>1.0.1</version>
  </dependency>

Detail Description of all Annotations

Flips provides various annotations to flip a feature. Let's have a detailed walk-through of all the annotations -

@FlipOnEnvironmentProperty is used to flip a feature based on the value of an environment property.

Usage

@Component
class EmailSender{

  @FlipOnEnvironmentProperty(property="feature.send.email", expectedValue="true")
  public void sendEmail(EmailMessage emailMessage){
  }
}

Feature sendEmail is enabled if the property feature.send.email is set to true.

@FlipOnProfiles is used to flip a feature based on the envinronment in which the application is running.

Usage

@Component
class EmailSender{

  @FlipOnProfiles(activeProfiles={"dev", "qa"})
  public void sendEmail(EmailMessage emailMessage){
  }
}

Feature sendEmail is enabled if the current profile is either dev or qa.

@FlipOnDaysOfWeek is used to flip a feature based on the day of the week.

Usage

@Component
class EmailSender{

  @FlipOnDaysOfWeek(daysOfWeek={DayOfWeek.MONDAY,DayOfWeek.TUESDAY})
  public void sendEmail(EmailMessage emailMessage){
  }
}

Feature sendEmail is enabled if current day is either MONDAY or TUESDAY.

@FlipOnDateTime is used to flip a feature based on date and time.

Usage

@Component
class EmailSender{

  @FlipOnDateTime(cutoffDateTimeProperty="default.date.enabled")
  public void sendEmail(EmailMessage emailMessage){
  }
}

Feature sendEmail is enabled if current datetime is equal to or greater than the value defined by the default.date.enabled property.

@FlipOnSpringExpression is used to flip a feature based on the evaluation of spring expression.

Usage

@Component
class EmailSender{

  @FlipOnSpringExpression(expression = "T(java.lang.Math).sqrt(4) * 100.0 < T(java.lang.Math).sqrt(4) * 10.0")
  public void sendEmail(EmailMessage emailMessage){
  }
}

Feature sendEmail is enabled if the expression evaluates to TRUE.

@FlipBean is used to flip the invocation of a method with another method. It is most likely to be used in conjunction with @FlipOn... annotation.

Usage

@Component
class EmailSender{

  @FlipBean(with=SendGridEmailSender.class)
  public void sendEmail(EmailMessage emailMessage){
  }
}

will flip the invocation of sendEmail method with the one (having exactly same signature) defined in SendGridEmailSender.

@FlipOff is used to flip a feature off.

Usage

@Component
class EmailSender{

  @FlipOff
  public void sendEmail(EmailMessage emailMessage){
  }
}

Feature sendEmail is always DISABLED.

FAQs

1. Is there a way to combine these annotations ? Eg; I want a feature to be enabled only on PROD environment but after a given date.

Yes, these annotations can be combined. Currently, such combinations are treated as AND operations, meaning all the conditions MUST evaluate to TRUE for a feature to be enabled.

Usage

@Component
class EmailSender{

  @FlipOnProfiles(activeProfiles = "PROD")
  @FlipOnDateTime(cutoffDateTimeProperty = "sendemail.feature.active.after")
  public void sendEmail(EmailMessage emailMessage){
  }
}

this will throw FeatureNotEnabledException is either of the conditions evaluate to FALSE

2. Is there a way to flip a bean based on conditions ? Eg; I want a feature to be flipped with only in DEV.

Yes, @FlipBean can be used with conditions. If used with conditions, flip bean will be activated if all the conditions evaluate to TRUE

Usage

@Component
class EmailSender{

  @FlipBean(with=SendGridEmailSender.class)
  @FlipOnProfiles(activeProfiles = "DEV")
  public void sendEmail(EmailMessage emailMessage){
  }
}

this will flip the implementation of sendEmail with the same method defined in SendGridEmailSenderif active profile is DEV.

3. What date format is accepted in FlipOnDateTime ?

ISO-8601.

Usage

@Component
class EmailSender{

  @FlipOnDateTime(cutoffDateTimeProperty = "sendemail.feature.active.after")
  public void sendEmail(EmailMessage emailMessage){
  }
}

Assuming, today is 20th Sep 2018, one could set sendemail.feature.active.after to a value equal to before 20th Sep 2018. sendemail.feature.active.after=2018-09-16T00:00:00Z

4. What happens on invoking a disabled feature ?

FeatureNotEnabledException is thrown if a disabled feature is invoked. In case of a WEB application, one could use flips-web dependency which also provides ControllerAdvice meant to handle this exception. It returns a default response and a status code of 501.

5. Is it possible for the client of this library to override the response returned by ControllerAdvice ?

Yes, this is doable. You can register your ControllerAdvice with an exception handler meant for handling FeatureNotEnabledException. Please refer Sample Project.

6. What should be the signature of target method while using @FlipBean

The target method should have exactly the same signature as the method which is annotated with @FlipBean annotation.
Please refer "getArticleStatisticsByYear" method Sample Project.

7. How do I load Spring Configuration related to Flips ?

In order to bring all Flips related annotations in effect, FlipConfiguration needs to be imported.

Usage

@SpringBootApplication
@Import(FlipWebContextConfiguration.class)
class ApplicationConfig{
  public static void main(String[] args) {
    SpringApplication.run(ApplicationConfig.class, args);
  }
}

you will need to import FlipWebContextConfiguration as mentioned above. Please refer Sample Project.

8. Is there a way to create custom annotation(s) to flip a feature ?

Yes. You can create a custom annotation to fit your use case. Create a custom annotation at METHOD level which has a meta-annotation of type @FlipOnOff.

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@FlipOnOff(value = MyCustomCondition.class)
public @interface MyCustomAnnotation {
}

As a part of this annotation, specify the condition which will evaluate the result of this annotation.

@Component
public class MyCustomCondition implements FlipCondition {

  @Override
  public boolean evaluateCondition(FeatureContext featureContext, 
                                   FlipAnnotationAttributes flipAnnotationAttributes) {
    return false;
  }
}

This Condition class needs to implement FlipCondition and MUST be a Spring Component. This is it !!

9. How do I get to see all the methods which are annotated with Flip annotations along with their status ?

This functionality is available in flips-web as a REST endpoint. You can hit /describe/features to see the features and their status.

Want to contribute?

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Share feedback

Please use Github issues to share feedback, feature suggestions and report issues.

Credits

  1. A big Thank you to Sunit Parekh for providing his guidance
  2. Prateek Shah
  3. Yashica
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].