This is a technology demo for ZIO and its ecosystem, as well as integration with Cats-based libraries.
The utility uses the OpenWeatherMap API to stream weather data for configured locations, perform some mildly interesting transformations like batching, and record it in a Postgres database.
There are doobie- and quill-based data layer implementations. The layer of choice can be injected with .provide()
in Main.run()
, but doobie
(default) is highly recommended due to much smaller binary size, as well as the ability to insert a dynamically-sized list of records in one SQL statement (i.e. INSERT... VALUES (???), (???), (???), ...
). Quill
's compile-time queries are impressive, but not without limitations in practical usage.
By default, a postgres
database is needed to run the demo. The schema can be found here.
Alternatively, to simply log data to console, one could comment out the database stage of the stream in Main.run()
:
//.mapZIO:
// writeSamples
An example configuration file is provided in the main resource directory. It is fairly self-explanatory, and allows configuring the data layers, as well as the OpenWeatherMap client.
You can compile code with sbt compile
, run it with sbt run
.
The project can also be built as a Debian package. It installs to /opt/weather-zio
as a systemd
service. This is, of course, configurable in build.sbt
. See SBT Native Packager docs for reference.
sbt debian:packageBin
find target -name *.deb