python-dependency-injector/docs/tutorials/asyncio.rst

58 lines
1.2 KiB
ReStructuredText
Raw Normal View History

2020-08-06 05:26:37 +03:00
Asyncio daemon tutorial
=======================
2020-08-06 05:26:37 +03:00
.. _asyncio-daemon-tutorial:
This tutorials shows how to build an ``asyncio`` daemon following the dependency injection
principle.
Start from the scratch or jump to the section:
.. contents::
:local:
:backlinks: none
You can find complete project on the
`Github <https://github.com/ets-labs/python-dependency-injector/tree/master/examples/miniapps/monitoring-daemon-asyncio>`_.
What are we going to build?
---------------------------
2020-08-06 06:32:15 +03:00
We will build a monitoring daemon that monitors web services availability.
The daemon will send the requests to the `example.com <http://example.com>`_ and
`httpbin.org <https://httpbin.org>`_ every couple of seconds. For each successfully completed
response it will log:
- The response code
- The amount of bytes in the response
- The time took to complete the response
.. image:: asyncio_images/diagram.png
2020-08-06 05:26:37 +03:00
Prepare the environment
-----------------------
Project layout
--------------
Install the requirements
------------------------
Minimal application
-------------------
HTTP monitor
------------
Add another monitor
-------------------
Tests
-----
Conclusion
----------
.. disqus::