Giter Site home page Giter Site logo

learningbyexample / reactive-ms-example Goto Github PK

View Code? Open in Web Editor NEW
175.0 11.0 74.0 687 KB

An educational project to learn reactive programming with Spring 5

License: MIT License

Shell 6.84% Batchfile 4.85% Java 83.24% HTML 5.06%
reactive-microservices spring-webflux spring-boot reactor api-rest apis java microservices reactive spring

reactive-ms-example's Introduction

Reactive Micro Services Example

License: MIT Build Status codecov codebeat badge

info

This is an example of doing reactive MicroServices using spring 5 functional web framework and spring boot 2.

There is a Kotlin fork of this service.

This service provide and API that will get the geo location and the sunrise and sunset times from an address.

Scenario: Get Location
  Given I've an address
  When I call the location service
  Then I should get a geo location
  And I should get the sunrise and sunset times

To implement this example we consume a couple of REST APIs.

This example cover several topics:

  • Functional programing.
  • Reactive types.
  • Router Functions.
  • Static Web-Content.
  • Creation on Reactive Java Services/Components.
  • Error handling in routes and services.
  • Reactive Web Client to consume external REST Services.
  • Organizing your project in manageable packaging.

Includes and in depth look to testing using JUnit5:

  • Unit, Integration and System tests.
  • Mocking, including reactive functions and JSON responses.
  • BDD style assertions.
  • Test tags with maven profiles.

usage

To run this service:

$ mvnw spring-boot:run

Sample requests

Get from address

$ curl -X GET "http://localhost:8080/api/location/Trafalgar%20Square%2C%20London%2C%20England" -H  "accept: application/json"

Post from JSON

$ curl -X POST "http://localhost:8080/api/location" -H  "accept: application/json" -H  "content-type: application/json" -d "{  \"address\": \"Trafalgar Square, London, England\"}"

Both will produce something like:

{
  "geographicCoordinates": {
    "latitude": 51.508039,
    "longitude": -0.128069
  },
  "sunriseSunset": {
    "sunrise": "2017-05-21T03:59:08+00:00",
    "sunset": "2017-05-21T19:55:11+00:00"
  }
}

All date and times are ISO 8601 UTC without summer time adjustment

API

View in the embedded Swagger UI View in the embedded Swagger UI

Run in Postman Run in Postman

Project Structure

References

reactive-ms-example's People

Contributors

jabrena avatar juan-medina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactive-ms-example's Issues

Update Docs

Update:

  • Readme MD
  • Swagger Docs
  • Postman Request

compile issues when upgrade the starter-parent from 2.0.0.M1 to 2.0.0.RELEASE

Thanks for your excellent examples!
I can not compile the original project duo to missing some snapshot jars, so I upgrade the pom from M1 to release.
But then there are some errors:

//org.learning.by.example.reactive.microservices.handlers.ApiHandler L45

 return address
                .transform(geoLocationService::fromAddress)
                .and(this::sunriseSunset, LocationResponse::new)
                .transform(this::serverResponse);

in the documents:
public final Mono<Void> and(Publisher<?> other)

So, I think the method and should only have one param, so it is failed to compile.

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.