produce

class kafkaaggregator.cli.produce(ctx: click.core.Context, *args, key_serializer: Union[faust.types.codecs.CodecT, str, None] = None, value_serializer: Union[faust.types.codecs.CodecT, str, None] = None, **kwargs)

Bases: faust.cli.base.AppCommand

Produce messages for the aggregation example.

Attributes Summary

abstract
blocking_timeout Return the blocking timeout used for this command.
builtin_options
console_port Return the :pypi:`aiomonitor` console port.
daemon
loglevel Return the log level used for this command.
options
prog_name
redirect_stdouts
redirect_stdouts_level
require_app

Methods Summary

__call__(*args, **kwargs) Call command-line command.
abbreviate_fqdn(name, *, prefix) Abbreviate fully-qualified Python name, by removing origin.
as_click_command() Convert command into :pypi:`click` command.
as_service(loop, *args, **kwargs) Wrap command in a mode.Service object.
bold(text) Return text in bold.
bold_tail(text, *, sep) Put bold emphasis on the last part of a foo.bar.baz string.
carp(s, **kwargs) Print something to stdout (or use file=stderr kwargs).
color(name, text) Return text having a certain color by name.
dark(text) Return cursor text.
dumps(obj) Serialize object using JSON.
execute(*args, **kwargs) Execute command.
from_handler(*options, **kwargs) Decorate async def command to create command class.
import_relative_to_app(attr) Import string like “module.Model”, or “Model” to model class.
on_stop() Call after command executed.
on_worker_created(worker) Call when creating faust.Worker to execute this command.
parse(argv) Parse command-line arguments in argv and return mapping.
run(frequency, max_messages) Produce messages for the aggregation example.
run_using_worker(*args, **kwargs) Execute command using faust.Worker.
say(message, file, err, **kwargs) Print something to stdout (or use file=stderr kwarg).
table(data, title, **kwargs) Format table data as ANSI/ASCII table.
tabulate(data, headers, wrap_last_row, …) Create an ANSI representation of a table of two-row tuples.
to_key(typ, key) Convert command-line argument string to model (key).
to_model(typ, value, serializer, str, None]) Convert command-line argument to model.
to_topic(entity) Convert topic name given on command-line to app.topic().
to_value(typ, value) Convert command-line argument string to model (value).
worker_for_service(service, loop) Create faust.Worker instance for this command.

Attributes Documentation

abstract = False
blocking_timeout

Return the blocking timeout used for this command.

builtin_options = [<function version_option.<locals>.decorator>, option('--app', '-A', help='Path of Faust application to use, or the name of a module.'), option('--quiet/--no-quiet', '-q', default=False, help='Silence output to <stdout>/<stderr>.'), option('--debug/--no-debug', default=False, help='Enable debugging output, and the blocking detector.'), option('--no-color/--color', '--no_color/--color', default=False, help='Enable colors in output.'), option('--workdir', '-W', default=None, type=<click.types.Path object>, help='Working directory to change to after start.'), option('--datadir', '-D', default='{conf.name}-data', type=<click.types.Path object>, help='Directory to keep application state.'), option('--json', default=False, is_flag=True, help='Return output in machine-readable JSON format'), option('--loop', '-L', default='aio', type=Choice('['aio', 'eventlet', 'uvloop']'), help='Event loop implementation to use.'), option('--logfile', '-f', callback=<function compat_option.<locals>._callback>, expose_value=False, default=None, type=<click.types.Path object>, help='Path to logfile (default is <stderr>).'), option('--loglevel', '-l', callback=<function compat_option.<locals>._callback>, expose_value=False, default='WARN', type=Choice('['crit', 'error', 'warn', 'info', 'debug']'), help='Logging level to use.'), option('--blocking-timeout', callback=<function compat_option.<locals>._callback>, expose_value=False, default=10.0, type=<class 'float'>, help='when --debug: Blocking detector timeout.'), option('--console-port', callback=<function compat_option.<locals>._callback>, expose_value=False, default=50101, type=IntRange(1, 65535), help='when --debug: Port to run debugger console on.')]
console_port

Return the :pypi:`aiomonitor` console port.

daemon = False
loglevel

Return the log level used for this command.

options = (option('--frequency', type=<class 'float'>, default=10.0, help='The frequency in Hz in wich messages are produced.'), option('--max-messages', type=<class 'int'>, default=10, help='The maximum number of messages to produce.'))
prog_name = ''
redirect_stdouts = None
redirect_stdouts_level = None
require_app = True

Methods Documentation

__call__(*args, **kwargs) → NoReturn

Call command-line command.

This will raise SystemExit before returning, and the exit code will be set accordingly.

abbreviate_fqdn(name: str, *, prefix: str = '') → str

Abbreviate fully-qualified Python name, by removing origin.

app.conf.origin is the package where the app is defined, so if this is examples.simple it returns the truncated:

>>> app.conf.origin
'examples.simple'
>>> abbr_fqdn(app.conf.origin,
...           'examples.simple.Withdrawal',
...           prefix='[...]')
'[...]Withdrawal'

but if the package is not part of origin it provides the full path:

>>> abbr_fqdn(app.conf.origin,
...           'examples.other.Foo', prefix='[...]')
'examples.other.foo'
classmethod as_click_command() → Callable

Convert command into :pypi:`click` command.

as_service(loop: asyncio.events.AbstractEventLoop, *args, **kwargs) → mode.types.services.ServiceT

Wrap command in a mode.Service object.

bold(text: str) → str

Return text in bold.

bold_tail(text: str, *, sep: str = '.') → str

Put bold emphasis on the last part of a foo.bar.baz string.

carp(s: Any, **kwargs) → None

Print something to stdout (or use file=stderr kwargs).

Note:
Does not do anything if the --debug option is enabled.
color(name: str, text: str) → str

Return text having a certain color by name.

Examples::
>>> self.color('blue', 'text_to_color')
>>> self.color('hiblue', text_to_color')
See Also:
:pypi:`colorclass`: for a list of available colors.
dark(text: str) → str

Return cursor text.

dumps(obj: Any) → str

Serialize object using JSON.

execute(*args, **kwargs) → Any

Execute command.

classmethod from_handler(*options, **kwargs) → Callable[[Callable], Type[faust.cli.base.AppCommand]]

Decorate async def command to create command class.

import_relative_to_app(attr: str) → Any

Import string like “module.Model”, or “Model” to model class.

on_stop() → None

Call after command executed.

on_worker_created(worker: mode.worker.Worker) → None

Call when creating faust.Worker to execute this command.

classmethod parse(argv: Sequence[str]) → Mapping

Parse command-line arguments in argv and return mapping.

run(frequency: float, max_messages: int) → None

Produce messages for the aggregation example.

run_using_worker(*args, **kwargs) → NoReturn

Execute command using faust.Worker.

say(message: str, file: IO = None, err: IO = None, **kwargs) → None

Print something to stdout (or use file=stderr kwarg).

Note:
Does not do anything if the --quiet option is enabled.
table(data: Sequence[Sequence[str]], title: str = '', **kwargs) → terminaltables.base_table.BaseTable

Format table data as ANSI/ASCII table.

tabulate(data: Sequence[Sequence[str]], headers: Sequence[str] = None, wrap_last_row: bool = True, title: str = '', title_color: str = 'blue', **kwargs) → str

Create an ANSI representation of a table of two-row tuples.

See Also:
Keyword arguments are forwarded to terminaltables.SingleTable
Note:
If the --json option is enabled this returns json instead.
to_key(typ: Optional[str], key: str) → Any

Convert command-line argument string to model (key).

Arguments:
typ: The name of the model to create. key: The string json of the data to populate it with.
Notes:
Uses key_serializer to set the codec for the key (e.g. "json"), as set by the --key-serializer option.
to_model(typ: Optional[str], value: str, serializer: Union[faust.types.codecs.CodecT, str, None]) → Any

Convert command-line argument to model.

Generic version of to_key()/to_value().

Arguments:

typ: The name of the model to create. key: The string json of the data to populate it with. serializer: The argument setting it apart from to_key/to_value

enables you to specify a custom serializer not mandated by key_serializer, and value_serializer.
Notes:
Uses value_serializer to set the codec for the value (e.g. "json"), as set by the --value-serializer option.
to_topic(entity: str) → Any

Convert topic name given on command-line to app.topic().

to_value(typ: Optional[str], value: str) → Any

Convert command-line argument string to model (value).

Arguments:
typ: The name of the model to create. key: The string json of the data to populate it with.
Notes:
Uses value_serializer to set the codec for the value (e.g. "json"), as set by the --value-serializer option.
worker_for_service(service: mode.types.services.ServiceT, loop: asyncio.events.AbstractEventLoop = None) → mode.worker.Worker

Create faust.Worker instance for this command.