A service making use for this library and demoing all its features can be found here eks-spring-boot-jenkinsop-example
Credits and usages : This library makes use of these create projects
- https://springfox.github.io/springfox/
- https://github.com/Feature-Flip/flips
- https://spring.io/projects/spring-cloud
- https://spring.io/projects/spring-cloud-kubernetes
- https://spring.io/projects/spring-restdocs
Sections
Annotating the main service class with @EnableLogger
@SpringBootApplication
@EnableLogger
public class ReferenceApplication {
public static void main(String[] args) {
SpringApplication.run(ReferenceApplication.class, args);
}
}
Annotating a method will log the entry and exit of method along with arguments
@Loggable(value = LogLevel.INFO, name = "sayHello")
public String sayHello(String name) {
}
/**
* The log level {@link LogLevel}. (default: INFO)
*/
LogLevel value() default LogLevel.INFO;
/**
* The logger name. if not set, class name will be given.
*/
String name() default "";
/**
* Log method before its execution? (default: False)
*/
boolean entered() default false;
/**
* Skip log method with its results? (default: False)
*/
boolean skipResult() default false;
/**
* Skip log method with its arguments? (default: False)
*/
boolean skipArgs() default false;
/**
* List of exceptions that this logger should not log its stack trace. (default: None)
*/
Class<? extends Throwable>[] ignore() default {};
/**
* Should logger warn whenever method execution takes longer? (default: Forever)
*/
long warnOver() default -1;
/**
* Time unit for the warnOver. (default: MINUTES)
*/
TimeUnit warnUnit() default TimeUnit.MINUTES;
This lib leverages https://github.com/Feature-Flip/flips for feature flipping
In order to enable support please annotate the service class with @EnableBBDFlipToggles
@SpringBootApplication
@EnableBBDFlipToggles
@EnableLogger
public class ReferenceApplication {
public static void main(String[] args) {
SpringApplication.run(ReferenceApplication.class, args);
}
}
Method Annotation using a property switch from config
@FlipOnEnvironmentProperty(property = "service.feature.example", expectedValue = "true")
public RestApiResult<String> toggleExamplev2(@PathVariable("user") final String user) throws Exception {
return new RestApiResult<String>().withResult(demoService.getReposForUserMethod(user));
}
....
application.yaml
service:
feature:
example: false
props:
clients:
github:
baseUrl: https://api.github.com
For Other annotations see https://github.com/Feature-Flip/flips
A automatic controller will be available allowing you to issue get request to find the state of features. The path is /describe/
curl -s http://localhost:8080/describe/features | jq
[
{
"enabled": false,
"class": "com.bbdsoftware.service.reference.api.SampleApi",
"feature": "toggleExamplev2"
}
This library bundles in spring-cloud-kubernetes in order to leverage comfig maps for configuration
Please see https://github.com/spring-cloud/spring-cloud-kubernetes#5-kubernetes-propertysource-implementations for further details
Annotating the main service class with @EnableBBDSwagger .
@SpringBootApplication
@EnableBBDSwagger
public class ReferenceApplication {
public static void main(String[] args) {
SpringApplication.run(ReferenceApplication.class, args);
}
}
The library will configure the spring-fox library to scan for @RestControllers
for documentation in the configured packages
The swagger ui can be reached at /swagger-ui.html
bbd:
core:
swagger:
packages: com.bbdsoftware