From 13b8d1bab20e46e905c874db8775b684c3fb5ad0 Mon Sep 17 00:00:00 2001 From: Grant Williams Date: Wed, 21 Apr 2021 13:27:59 -0500 Subject: [PATCH 1/2] Add missing syntax highlighting to ReadMe example --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 78240634e..0b21b3185 100644 --- a/README.rst +++ b/README.rst @@ -178,6 +178,8 @@ Faust is... Here's one of the easier applications you can make:: +.. sourcecode:: python + import faust class Greeting(faust.Record): From ec1d3113e33bdd935b12fe5b5c91e4b2b4572a3f Mon Sep 17 00:00:00 2001 From: Grant Williams Date: Wed, 21 Apr 2021 13:28:48 -0500 Subject: [PATCH 2/2] fix indention --- README.rst | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/README.rst b/README.rst index 0b21b3185..5f0c654ad 100644 --- a/README.rst +++ b/README.rst @@ -180,39 +180,39 @@ Faust is... .. sourcecode:: python - import faust - - class Greeting(faust.Record): - from_name: str - to_name: str - - app = faust.App('hello-app', broker='kafka://localhost') - topic = app.topic('hello-topic', value_type=Greeting) - - @app.agent(topic) - async def hello(greetings): - async for greeting in greetings: - print(f'Hello from {greeting.from_name} to {greeting.to_name}') - - @app.timer(interval=1.0) - async def example_sender(app): - await hello.send( - value=Greeting(from_name='Faust', to_name='you'), - ) - - if __name__ == '__main__': - app.main() - - You're probably a bit intimidated by the `async` and `await` keywords, - but you don't have to know how ``asyncio`` works to use - Faust: just mimic the examples, and you'll be fine. - - The example application starts two tasks: one is processing a stream, - the other is a background thread sending events to that stream. - In a real-life application, your system will publish - events to Kafka topics that your processors can consume from, - and the background thread is only needed to feed data into our - example. + import faust + + class Greeting(faust.Record): + from_name: str + to_name: str + + app = faust.App('hello-app', broker='kafka://localhost') + topic = app.topic('hello-topic', value_type=Greeting) + + @app.agent(topic) + async def hello(greetings): + async for greeting in greetings: + print(f'Hello from {greeting.from_name} to {greeting.to_name}') + + @app.timer(interval=1.0) + async def example_sender(app): + await hello.send( + value=Greeting(from_name='Faust', to_name='you'), + ) + + if __name__ == '__main__': + app.main() + +You're probably a bit intimidated by the `async` and `await` keywords, +but you don't have to know how ``asyncio`` works to use +Faust: just mimic the examples, and you'll be fine. + +The example application starts two tasks: one is processing a stream, +the other is a background thread sending events to that stream. +In a real-life application, your system will publish +events to Kafka topics that your processors can consume from, +and the background thread is only needed to feed data into our +example. **Highly Available** Faust is highly available and can survive network problems and server