This is a tiny REST service managing counters. The counters are kept in memory, so they are reset every time you restart the service.
Each counter has
- a unique index (a number greater or equal 0) and
- a value.
You can either get or set a counter. Of course, you shouldn't set any counter in a distributed environment. Instead, you should get it and then use the increment or decrement operations on it. For presentations, it is a reasonable choice to set some counters before showing anything to your audience.
The RESTful Web Service runs at http://localhost:3000. Its Swagger UI is available at http://localhost:3000/swagger-ui/index.html and the OpenAPI description is available at http://localhost:3000/v3/api-docs.
$ ./gradlew bootRun
$ ./gradlew test
For the HTML report, see the directory build/reports/tests/test
.
This is generated everytime the unit tests are run. To do this separately:
$ ./gradlew jacocoTestReport
As usual, you'll find the HTML report in the directory build/reports/jacoco/test
.
$ ./gradlew build
$ docker build -t myorg/redux-server-spring .
$ docker run --rm -p 3000:3000 myorg/redux-server-spring
On my Mac, the image size is 433 MB, the container uses 228 MB RAM.
To build a native image, you have to have GraalVM installed, the environment variable GRAALVM_HOME
set and Docker
(or something compatible like Rancher Desktop) running on your host. For details, please see
the documentation.
$ ./gradlew bootBuildImage
$ docker run --rm -p 3000:3000 docker.io/library/redux-server-spring:0.0.1-SNAPSHOT
On my Mac, the image size is 129 MB, the container uses 146 MB RAM.
To check for dependency updates, please use
$ ./gradlew dependencyUpdates
This is only one possible solution to this kind of problem.
There are some implementations of single-page applications using the services which are implemented in different programming languages and frameworks.
Here's the full picture.
- https://github.com/MichaelKaaden/redux-client-ngrx (Angular with NgRx)
- https://github.com/MichaelKaaden/redux-client-ng5 (Angular
with
angular-redux
) - https://github.com/MichaelKaaden/redux-client-ng (AngularJS
with
ng-redux
)
- https://github.com/MichaelKaaden/redux-server-spring (Java with Spring Boot)
- https://github.com/MichaelKaaden/redux-server-rust (Rust
with
actix-web
) - https://github.com/MichaelKaaden/redux-server-golang (Go
with
Gin
) - https://github.com/MichaelKaaden/redux-server-nest (Node.js
with
Nest.js
) - https://github.com/MichaelKaaden/redux-server (Node.js
with
Express
)