Awesome API to calculate Fibonacci series
Awesome Simple API to calculate Fibonacci series for a given number.
AWS Fargate diagram
This API can be deployed on a serverless cluster using AWS Fargate. Pros:
Cons:
exec
direct to a container. It require other ways to debug/trace. Ex: spring actuator API
.In order to use the API, follow the credentials:
username: admin password: s3cr3t
1 - To calculate series for number 2
$ curl http://localhost:8080/api/calculate/2 \
--header 'accept: application/json' \
--header 'authorization: Basic YWRtaW46czNjcjN0'
[
1,
1
]
2 - To health check
$ curl --request GET \
--url http://localhost:8080/actuator/health \
--header 'accept: application/json' \
--header 'authorization: Basic YWRtaW46czNjcjN0'
{
"status": "UP"
}
3 - To shutdown application for HA testing purposes
$ curl --request POST \
--url http://localhost:8080/actuator/shutdown \
--header 'accept: application/json' \
--header 'authorization: Basic YWRtaW46czNjcjN0'
{
"message": "Shutting down, bye..."
}
You can use the /actuator
API to get several information about the service. Just do a GET:
$ curl --request GET \
--url http://localhost:8080/actuator/ \
--header 'accept: application/json' \
--header 'authorization: Basic YWRtaW46czNjcjN0'
{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"beans": {
"href": "http://localhost:8080/actuator/beans",
"templated": false
},
"caches-cache": {
"href": "http://localhost:8080/actuator/caches/{cache}",
"templated": true
},
...
}
}
In order to run, install gradle 5.6 and run gradle build
on repo path.
docker images
docker container ls
docker logs <container_name>
docker container rm <container_name
docker image rm <image_name
To facilitate dev setup, there is an virtual box provisioned using Ansible. To use it:
1 - Install Vagrant 2.2.5
or higher
2 - Install VirtualBox 6.0
or higher
3 - Initialize vm by running on directory`s repo
git clone https://github.com/rgalba/fibonacci-api
cd fibonacci-api
vagrant up
4 - Access machine by running:
vagrant ssh
The
/vagrant
folder will be mounted with project root dir content.
5 - Build project
gradle build
6 - Run the app
gradle bootRun