This application uses PHP 8 e Kafka to translate IPs into geographical locations using the IPStack free API.
- A PHP process consumes a Kafka Topic entry
- Incoming messages are sent to IPStack
- A new message is created using the returned IP geolocation data
- The new message is sent to a Kafka Topic output
- The request per client + IP is cached in Redis for 30 minutes.
- Get free API Access Key and put the value in .env variable
IPSTACK_ACCESS_KEY
- Run docker-compose up -d
- done.
- Start consume the output kafka topic running
./bin/consume-output-topic.sh
- Open a Kafka Producer running
./bin/open-input-producer.sh
and send a new message:
Input message sample:{"ip": "2001:1284:f013:2c2c:13d9:135d:aff9:c52d", "clientId": 1}
- A message with the ip geolocation will appear in the consumer window.
Output message example
{ "ip": "2001:1284:f013:2c2c:13d9:135d:aff9:c52d", "timestamp": 1647020864, "clientId": 1, "latitude": -25.427776336669922, "longitude": -49.27305221557617, "country": "Brazil", "region": "Parana", "city": "Curitiba" }
./bin/unit-tests.sh
- Implement logs using syslog pattern.
- Test coverage report.