Skip to content

Commit

Permalink
Showing 11 changed files with 81 additions and 31 deletions.
2 changes: 0 additions & 2 deletions TODO.rst
Original file line number Diff line number Diff line change
@@ -216,8 +216,6 @@ Documentation

- acknowledgements

- Serialization

- Sensors

- Deployment
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -46,3 +46,5 @@
html_theme = 'alabaster'
html_sidebars = {}
templates_path = ['_templates']

autodoc_member_order = 'bysource'
21 changes: 21 additions & 0 deletions docs/userguide/deployment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _guide-deployment:

===========================================
Deployment
===========================================

.. contents::
:local:
:depth: 1

.. module:: faust

.. currentmodule:: faust

* daemonization

* uvloop vs. asyncio

* debugging (aiomonitor)

* logging
13 changes: 13 additions & 0 deletions docs/userguide/http.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. _guide-http:

===========================================
HTTP API
===========================================

.. contents::
:local:
:depth: 1

.. module:: faust

.. currentmodule:: faust
2 changes: 2 additions & 0 deletions docs/userguide/index.rst
Original file line number Diff line number Diff line change
@@ -16,4 +16,6 @@
tables
models
sensors
deployment
http
vskafka
17 changes: 17 additions & 0 deletions docs/userguide/sensors.rst
Original file line number Diff line number Diff line change
@@ -77,38 +77,55 @@ Monitor Attributes
:noindex:

.. autoattribute:: messages
:annotation:

.. autoattribute:: messages_active
:annotation:

.. autoattribute:: messages_received_total
:annotation:

.. autoattribute:: messages_received_by_topic
:annotation:

.. autoattribute:: messages_s
:annotation:

.. autoattribute:: events_active
:annotation:

.. autoattribute:: events_total
:annotation:

.. autoattribute:: events_s
:annotation:

.. autoattribute:: events_by_stream
:annotation:

.. autoattribute:: events_by_task
:annotation:

.. autoattribute:: events_runtime
:annotation:

.. autoattribute:: events_runtime_avg
:annotation:

.. autoattribute:: tables
:annotation:

.. autoattribute:: commit_latency
:annotation:

.. autoattribute:: send_latency
:annotation:

.. autoattribute:: messages_sent
:annotation:

.. autoattribute:: messages_sent_by_topic
:annotation:

.. _monitor-configuration:

31 changes: 12 additions & 19 deletions examples/simple.py
Original file line number Diff line number Diff line change
@@ -20,26 +20,19 @@ class Withdrawal(faust.Record, serializer='json'):
)


#@app.task(concurrency=1)
#async def find_large_withdrawals(app):
# if GRAPH:
# asyncio.ensure_future(_dump_beacon(app))
# withdrawals = app.stream(topic)
# user_to_total = withdrawals.sum(Withdrawal.amount, 'user_to_total',
# key=Withdrawal.user)
# country_to_total = withdrawals.sum(Withdrawal.amount, 'country_to_total',
# key=Withdrawal.country)
# async for withdrawal in withdrawals:
# print('Withdrawal: %r, User Total: %r, Country Total: %r' %
# (withdrawal, user_to_total[withdrawal.user],
# country_to_total[withdrawal.country]))


@app.task(concurrency=10)
@app.task(concurrency=1)
async def find_large_withdrawals(app):
async for withdrawal in app.stream(topic):
if withdrawal.amount > 1000.0:
print('Found large withdrawal: %r' % (withdrawal,))
if GRAPH:
asyncio.ensure_future(_dump_beacon(app))
withdrawals = app.stream(topic)
user_to_total = withdrawals.sum(Withdrawal.amount, 'user_to_total',
key=Withdrawal.user)
country_to_total = withdrawals.sum(Withdrawal.amount, 'country_to_total',
key=Withdrawal.country)
async for withdrawal in withdrawals:
print('Withdrawal: %r, User Total: %r, Country Total: %r' %
(withdrawal, user_to_total[withdrawal.user],
country_to_total[withdrawal.country]))


async def _dump_beacon(app):
17 changes: 9 additions & 8 deletions faust/__init__.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import re
import sys
import typing
from typing import NamedTuple
from typing import Any, Mapping, NamedTuple, Sequence

__version__ = '1.0.0'
__author__ = 'Robinhood Markets'
@@ -75,7 +75,7 @@ def use_uvloop() -> None:
# - See werkzeug/__init__.py for the rationale behind this.
from types import ModuleType # noqa

all_by_module = {
all_by_module: Mapping[str, Sequence[str]] = {
'faust.app': ['App'],
'faust.models': ['Record'],
'faust.sensors': ['Monitor', 'Sensor'],
@@ -97,18 +97,19 @@ def use_uvloop() -> None:
object_origins[item] = module


class module(ModuleType):
class _module(ModuleType):
"""Customized Python module."""

def __getattr__(self, name):
def __getattr__(self, name: str) -> Any:
if name in object_origins:
module = __import__(object_origins[name], None, None, [name])
module = __import__(
object_origins[name], None, None, [name])
for extra_name in all_by_module[module.__name__]:
setattr(self, extra_name, getattr(module, extra_name))
return getattr(module, name)
return ModuleType.__getattribute__(self, name)

def __dir__(self):
def __dir__(self) -> Sequence[str]:
result = list(new_module.__all__)
result.extend(('__file__', '__path__', '__doc__', '__all__',
'__docformat__', '__name__', '__path__',
@@ -121,10 +122,10 @@ def __dir__(self):
# keep a reference to this module so that it's not garbage collected
old_module = sys.modules[__name__]

new_module = sys.modules[__name__] = module(__name__)
new_module = sys.modules[__name__] = _module(__name__)
new_module.__dict__.update({
'__file__': __file__,
'__path__': __path__,
'__path__': __path__, # type: ignore
'__doc__': __doc__,
'__all__': tuple(object_origins),
'__version__': __version__,
2 changes: 1 addition & 1 deletion faust/utils/graphs/graph.py
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ def to_dot(self, fh: IO, *, formatter: GraphFormatterT = None) -> None:
"""
seen: Set = set()
draw = formatter or self.formatter
write = partial(print, file=fh)
write = partial(print, file=fh) # noqa: T101

def if_not_seen(fun: Callable[[Any], str], obj: Any) -> None:
if draw.label(obj) not in seen:
2 changes: 1 addition & 1 deletion faust/worker.py
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ def carp(self, msg: str, *args: Any, **kwargs: Any) -> None:

def _print(self, msg: str, file: IO = None, end: str = '\n') -> None:
if not self.quiet:
print(msg, file=file or self.stdout, end=end)
print(msg, file=file or self.stdout, end=end) # noqa: T003

def on_startup_finished(self) -> None:
self.loop.call_later(3.0, self._on_startup_finished)
3 changes: 3 additions & 0 deletions requirements/pkgutils.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
setuptools>=20.6.7
wheel>=0.29.0
flake8>=2.5.4
flake8-blind-except
flake8-comprehensions
flake8-pyi
tox>=2.3.1
sphinx2rst>=1.0
bumpversion

0 comments on commit ff4cf25

Please sign in to comment.