The word five-0
is a skateboard trick. I'm a huge fan of skateboarding and when I started to develop open source projects,
I decided to use skate tricks as project names.
The image bellow shows the five-0
architecture. Basically, five-0
is a microservice that read information from elasticsearch
and
make available through HTTP endpoints:
The sample data stored into elasticsearch is shown down below:
$ git clone https://github.com/greatjapa/five-0.git
$ cd five-0
$ make up
$ make load
The make up
command build the microservice code with maven and raise a docker container with it.
As database, we use elasticsearch (see docker-compose.yml
):
Five-0 has 2 endpoints:
- GET
/connection?city=\<city\>&depth=\<depth\>
As an example, you can try:
curl http://localhost:8080/connection?city=Rio%20de%20Janeiro
and the result will be:
[
{
"city" : "Belo Horizonte",
"steps" : 0
},
{
"city" : "São Paulo",
"steps" : 0
},
{
"steps" : 1,
"city" : "Campinas"
},
{
"city" : "Trindade",
"steps" : 2
}
]
you also may define a max depth as argument:
curl http://localhost:8080/connection?city=Rio%20de%20Janeiro&depth=2
the result is:
[
{
"city": "Belo Horizonte",
"steps": 0
},
{
"city": "São Paulo",
"steps": 0
},
{
"city": "Campinas",
"steps": 1
}
]
- GET
/time?city=\<city\>
The following example shows how this endpoint works:
curl http://localhost:8080/time?city=Rio%20de%20Janeiro
the result is:
[
{
"city": "Belo Horizonte",
"time": 2.29
},
{
"city": "São Paulo",
"time": 5.19
},
{
"city": "Campinas",
"time": 9.89
},
{
"city": "Trindade",
"time": 19.75
}
]