- Doc for developers https://developer.yr.no/
Необходимо написать небольшой сервис на JavaScript. (Backend мы реализовали на Python с FastAPI, Frontend будет с JavaScript для интерактивности. Нужно попробовать для фронтенда - htmx, Svelte).
доступный через собственный API, который выводит данные о ежедневной температуре в Москве на время около 14:00 на столько ближайших дней, сколько возможно. Для получения сводки о погоде нужно будет использовать API метеорологической службы yr.no. Сервис необходимо завернуть в Dockerfile, чтобы можно было запустить одной командой.
- Для сервиса и API должна быть осмысленная документация.
- Покрытие кода тестами, которые проверяют реальную работу кода.
- Кроме Москвы можно указать другую локацию по координатам. (Во избежания перегрузки, мы будем указывать локацию по городу, работа будет только по зарегистрированным городам в БД. Автор сервиса рекомендует использовать широту и долготу до 4 заков после запятой, также требует кешировать ответы по
Expired
иIf-Modified-Since
).- Населённый пункт можно найти по названию.
- Предусмотрена защита от перегрузки yr.no запросами через данный сервис(Кешируем)
- Доступен Web-интерфейс, позволяющий работать с сервисом не только через API, но и через браузер, как обычный пользователь.
- initialize data for DB
make init-db
- build image and run docker containers
docker compose up
- go swagger doc http://127.0.0.1:8000/docs
-
- start memcached container
sudo docker exec -it --user=root <id container> sh
- install telnet on alpine version https://gist.github.com/Ryanb58/9e63e186981090d4f2de8ec0ea420e1d
apk update apk add busybox-extras netstat -tulpn | grep LISTEN telnet 127.0.0.1 11211
- or use netcat-freebsd
apk add netcat-openbsd nc -C 127.0.0.1 11211
-
Before run test, start memcached
docker compose up memcached
-
Run tests locally in root dir
pytest ./tests
-
Check test coverage
coverage run -m pytest coverage report
- Need correctly handling status code 304 Not Modified
- Need add simple web interface
- Try better restructured modules and dirs. Good example https://github.com/mohamad-liyaghi/fast-commerce
- Need fully asynchronous code, prevent blocking event loop
- FTS in sqlite3, official doc - https://www.sqlite.org/fts5.html
- FTS in sqlite3, more examples - https://www.sqlitetutorial.net/sqlite-full-text-search/
- Sqlite3 Habr - https://habr.com/ru/articles/754400/
- PostgreSQL : Документация - https://postgrespro.ru/docs/postgresql/
- Weather API(s)
- Swagger specification - https://swagger.io/specification/
- Dockerfile start app - https://docs.docker.com/get-started/02_our_app/
- Makefiles and
make
- https://en.wikipedia.org/wiki/Make_(software), https://makefiletutorial.com/ - cmake vs make - https://www.incredibuild.com/blog/cmake-vs-make
- Caching in python libs. All of these implementations have the problem of unsafely threading.
Additional synchronization required.
- functools.cache - https://docs.python.org/3/library/functools.html#functools.cache
- cachetools - https://github.com/tkem/cachetools/
- cachelib - https://cachelib.readthedocs.io/en/stable/simple/
- boltons.cacheutils - https://boltons.readthedocs.io/en/latest/cacheutils.html
- Dockerfile and compose - https://docs.docker.com/compose/gettingstarted/
- relative-imports-in-python-3 - https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
- FastAPI app factory - https://testdriven.io/courses/fastapi-celery/app-factory/
- RFC 2616 - https://datatracker.ietf.org/doc/html/rfc2616
- Memcached docker compose environs - https://hub.docker.com/r/bitnami/memcached
- Memcached wiki - https://github.com/memcached/memcached/wiki
- Add curl in Alpine container - https://gist.github.com/bruno-brant/e119da3713a657036ff7e3446d98176a
- Examples Memcached commands, all args and descriptions https://book.hacktricks.xyz/network-services-pentesting/11211-memcache/memcache-commands
- Alpine, Bookworm and others Docker images - https://stackoverflow.com/questions/52083380/in-docker-image-names-what-is-the-difference-between-alpine-jessie-stretch-an
- Requirements format - https://pip.pypa.io/en/stable/reference/requirements-file-format/
- Importance, history, evolution and etc. memcached +/- - https://www.dragonflydb.io/guides/memcached
- Scaling smoothly: RevenueCat’s data-caching techniques for 1.2 billion daily API requests - https://www.revenuecat.com/blog/engineering/data-caching-revenuecat/