Instructions for geolocation-service
See instructions for retrieving the source code, start the application and information on how to interact with the api's. You should be able to start the application locally and test the various api's.
Install the following:
Git
SBT
Instructions:
1. git clone git@github.com:arcalderon/geolocation-service.git or extract geolocation-service.zip
2. cd geolocation-service
2. sbt run
3. Health Check Url: http://localhost:9000/v1/geolocation-service
GET Get All Addresses
http://localhost:9000/v1/geolocation-service/addresses
Get All Addresses
curl --request GET --url http://localhost:9000/v1/geolocation-service/addresses
Sample Response
{
status: 200,
result: {
addressResponses: [
{
address: "411 Brockton Ave, Abington, MA 02351, USA",
status: "FOUND",
location: {
lat: 42.100856,
lng: -70.9595332
}
},
{
address: "Invalid Address",
status: "NOT_FOUND",
location: null
}
]
},
errors: [ ]
}
Number of retries is supplied in configuration file under key retries= 5. The retry number represents the number of times it will actually "retry", as oppose to the actual number of times it was actually invoked. Hence, the number of invocations are # of retry + 1 when a geolocation is not returned.
What constitutes as a "unable to find geolacation" ? It is when the response it self does not contain any geolocation information, for example, a response as such:
{
"results" : [],
"status" : "ZERO_RESULTS"
}
For that matter also when perhaps an over rate-limit response occurs as such:
{
"error_message" : "You have exceeded your rate-limit for this API.",
"results" : [],
"status" : "OVER_QUERY_LIMIT"
}
When either of the two scenarios above occurs the application initiates a retry effort. If retries are exhausted then it returns:
{
status: 200,
result: {
addressResponses: [
{
address: "Invalid Address",
status: "NOT_FOUND",
location: null
}
]
},
errors: [ ]
}
The rate limiter will be handled in a static fashion as oppose to dynamically. It will be assumed that the number of api calls per second has been established and known ahead of time as an SLA.
It could have been done dynamically if the response contained:
1.http status code of 429
2.header information such as a "Retry-After" suggesting how long to wait before making a new request.
The googleapis API returns 200 http status code even when rate-limit is reached.
JSON output In regards to the "address" attribute in the final JSON output, the actual value will be the value of the attribute "formatted_address" in the response of the api call and not the one provided in the addresses.conf file.