GithubHelp home page GithubHelp logo

nzb15555196162 / bbd-spring-boot-web-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bbdsoftware/bbd-spring-boot-web-starter

0.0 1.0 0.0 31 KB

Starter for spring boot based services

Java 100.00%

bbd-spring-boot-web-starter's Introduction

Starter libs for spring Based Services


Reference Implementation

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


Sections

  1. Logging
  2. Flags
  3. Config with kubernetes
  4. Swagger with springfox

Logging

Enabling

Annotating the main service class with @EnableLogger

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

Usage

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) {
 
}

Customisations

/**
 * 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;

Feature Flags

This lib leverages https://github.com/Feature-Flip/flips for feature flipping

Enabling Support

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);
    }

}

Example usage

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

Example usage

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"
  }

Configuration

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

Swagger

Enabling

Annotating the main service class with @EnableBBDSwagger .

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

Configuration

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

bbd-spring-boot-web-starter's People

Contributors

kanzifucius avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.