This is a very basic example of a Faust application. Ordinarily, we wouldn't generate the records and send them through the Kafka server and process them within the same app. However, this is fine for the purposes of this demonstration. In a production environment, we'd probably connect to a remote Kafka server that is connected to multiple sources and publishing to multiple different topics simultaneously.
The Faust app controls the interaction between the Python code and the Kafka server. We use the agent decorator to add a function to process information published to a particular channel. This asynchronous function will be executed each time new data is pushed to the sample topic. In this recipe, the agent that we defined simply prints the information contained within the Record objects into the terminal.
The timer decorator defines a service that regularly performs some action at a specified interval. In our case, the timer sends a...