Giter Club home page Giter Club logo

reactor-utils's Introduction

Reactor Utils

toaster

This is not bread-utils, just the toaster

Installation

Maven

<repository>
  <id>hotire</id>
  <url>http://dl.bintray.com/hotire/utils</url>
</repository>

<dependency>
    <groupId>com.github.hotire</groupId>
    <artifactId>reactor-utils</artifactId>
    <version>0.0.5.2</version>
</dependency>

BindingUtils

commons-beanutils-based, springframework-core-convert-based

ServerRequest

  • queryParams

  • pathVariables

bind to instance of class type

Custom Convert

  • commons-beanutils

    • LocalDateTime.class
    • LocalDate.class
    • Year.class
    • Month.class
  • springframework-core-convert-based

    • Long.class
    • Boolean.class

bind

 public Mono<ServerResponse> handle(ServerRequest request) {
   Data data = bind(request, Data.class)
   ....
 }   

: All values of ServerRequest(queryParams, pathVariables) into ValueObject

bindToMono

  public Mono<ServerResponse> handle(ServerRequest request) {
    return bindToMono(request, Data.class)
      .filter(data -> {...})
      .map(data -> {...})
      .doOnError(error -> {...})
  }   

: All values of ServerRequest(queryParams, pathVariables) into Mono<ValueObject>

bindOne

  public Mono<ServerResponse> handle(ServerRequest request) {
    final String userId = bindOne(request, String.class).orElse(DEFAULT);
    ....
    ....
  }  

: One value of ServerRequest(queryParam, pathVariable) into Optional<ValueObject>

bindOneToMono

  public Mono<ServerResponse> handle(ServerRequest request) {
    return bindOneToMono(request, String.class)
      .map(userId -> userId.orElseThrow() -> {...})         
      .filter(userId -> {...})
      .map(userId -> {...})
      .doOnError(userId -> {...})
  }   

: One value of ServerRequest(queryParam, pathVariable) into Mono<Optional<ValueObject>>

MonoBackPressureSubscriber

MonoBackPressureSubscriber request to publisher and consume Mono then pull Mono from publisher

blog : https://blog.naver.com/gngh0101

reference : https://projectreactor.io/docs/core/release/reference/

MDC

Thread-local based MDC is difficult when you switch thread in Webflux.

If you want to maintain MDC, similarly the thread, MDC must also switch.

How to use

class Configuration {
  static {
    Schedulers.addExecutorServiceDecorator(MDCScheduledExecutorServiceDecorator.class.getName(),
          (scheduler, scheduledExecutorService) -> new MDCScheduledExecutorServiceDecorator(scheduledExecutorService));
  }
}

reactor-utils's People

Contributors

hotire 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.