Coder Social home page Coder Social logo

romalev / reactive-spring-web-flux-service Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 3.0 89 KB

Simple POC of nonblocking REST service based on spring-web-flux which is backed by Netty.

Java 100.00%
spring-boot web-flux netty reactor gradle java-8 functional-programming reactive-programming reactive-streams poc rest http-server integration-testing

reactive-spring-web-flux-service's Introduction

POC of reactive service based on spring reactor & web-flux

Introduction

This is simple proof of concept of non-blocking rest service which is based on web-flux module (backed by netty) from spring.

Notes:

  • there's no tomcat (jetty, wildfly, weblogic or any other servlet or application container) dependency on the classpath.*
  • default number of threads for requests handling is determined by spring boot that is using Reactor Netty, which is using Netty's defaults.
  • gson is used to encode incoming json to service's dto objects and decode dto objects to outgoing json messages. Current implementation simply relies on plain toJson and fromJson methods without any extra configuration (which might be needed.)

Run the application

Service's requirements:

  • java 8+;
  • gradle 4.x+

In order to run the service execute in shell : ./gradlew bootRun. You should be able to see the service's log messages.

Hit http://localhost:7777/rest-service/hello endpoint to verify whether service has started correctly - you should be able to see the "hello reply message".

Currently the service's default port on which it is going to accepts incoming requests is 7777. You can change it in application.properties which is located under resources folder (look for server.port property).

Service's REST API

See the list of avalilable endpoint below.

Math operation Method Content Type URL Request Body Example Response Body Example
x+y POST application/json http://localhost:7777/rest-service/add {
"x": "[x_value]",
"y": "[y_value]"
}
{
"result": "[result]",
"message": "[additional details]"
}
x-y POST application/json http://localhost:7777/rest-service/sub {
"x": "[x_value]",
"y": "[y_value]"
}
{
"result": "[result]",
"message": "[additional details]"
}
x/y POST application/json http://localhost:7777/rest-service/divide {
"x": "[x_value]",
"y": "[y_value]"
}
{
"result": "[result]",
"message": "[additional details]"
}
x*y POST application/json http://localhost:7777/rest-service/multiply {
"x": "[x_value]",
"y": "[y_value]"
}
{
"result": "[result]",
"message": "[additional details]"
}
x^2 - sqrt(y) POST application/json http://localhost:7777/rest-service/inPowerOf2SubSqrt {
"x": "[x_value]",
"y": "[y_value]"
}
{
"result": "[result]",
"message": "[additional details]"
}

reactive-spring-web-flux-service's People

Contributors

romalev avatar

Stargazers

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