An extension of the Kotlin ktor starter sample that fetches data from a REST API and stores it in a DB.
-
Run docker-compose. This would start a postgres database in docker that can be connected to using the url localhost and port 555
./docker-compose up
-
If you are using a separate database from that provided with docker, run the create-database.sh script to create the necessary databases.
./databases/init-scripts/create-database.sh
-
You may need to make the script executable first
chmod +x ./databases/init-scripts/create-database.sh
-
Set the environment variables. These values are typical if using the docker database
export DB_USER=weather5028 export DB_PASS=weather5028 export DB_URL=localhost export DB_PORT=5555
-
Run the data-collector-server. This connects to the Weather Api, fetches the current weather info for London and stores it in the database
./gradlew a:data-collector-server:run
-
Connect to the database using pgAdmin and observe the new entry in the weather_snapshot table
./gradlew a:data-collector-server:run