MCPcopy Index your code
hub / github.com/LearningByExample/reactive-ms-example

github.com/LearningByExample/reactive-ms-example @1.1.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.1.2 ↗ · + Follow
445 symbols 2,100 edges 44 files 0 documented · 0% updated 8y ago★ 178

Browse by type

Functions 396 Types & classes 49
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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

  • https://spring.io/blog/2016/09/22/new-in-spring-5-functional-web-framework
  • https://spring.io/blog/2017/02/23/spring-framework-5-0-m5-update
  • http://junit.org/junit5/docs/current/user-guide/#running-tests-build-maven
  • https://github.com/junit-team/junit5-samples
  • https://developers.google.com/maps/documentation/geocoding/intro
  • https://sunrise-sunset.org/api
  • https://en.wikipedia.org/wiki/ISO_8601

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 245
Method 151
Class 47
Interface 2

Languages

TypeScript55%
Java45%

Modules by API surface

src/main/resources/public/swagger-ui-bundle.js169 symbols
src/main/resources/public/swagger-ui.js51 symbols
src/main/java/org/learning/by/example/reactive/microservices/model/GeoLocationResponse.java28 symbols
src/main/resources/public/swagger-ui-standalone-preset.js25 symbols
src/test/java/org/learning/by/example/reactive/microservices/routers/ApiRouterTests.java13 symbols
src/test/java/org/learning/by/example/reactive/microservices/services/GeoLocationServiceImplTests.java11 symbols
src/test/java/org/learning/by/example/reactive/microservices/handlers/ApiHandlerTests.java11 symbols
src/test/java/org/learning/by/example/reactive/microservices/handlers/ThrowableTranslatorTest.java10 symbols
src/test/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImplTests.java9 symbols
src/main/java/org/learning/by/example/reactive/microservices/model/GeoTimesResponse.java8 symbols
src/main/java/org/learning/by/example/reactive/microservices/handlers/ApiHandler.java7 symbols
src/main/java/org/learning/by/example/reactive/microservices/services/SunriseSunsetServiceImpl.java6 symbols

For agents

$ claude mcp add reactive-ms-example \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page