produce¶
- class kafkaaggregator.cli.produce(ctx: Context, *args: Any, key_serializer: Optional[Union[CodecT, str]] = None, value_serializer: Optional[Union[CodecT, str]] = None, **kwargs: Any)¶
Bases:
AppCommandProduce messages for the aggregation example.
Attributes Summary
Return the blocking timeout used for this command.
Return the :pypi:`aiomonitor` console port.
Return the log level used for this command.
Methods Summary
__call__(*args, **kwargs)Call command-line command.
abbreviate_fqdn(name, *[, prefix])Abbreviate fully-qualified Python name, by removing origin.
Convert command into :pypi:`click` command.
as_service(loop, *args, **kwargs)Wrap command in a
mode.Serviceobject.bold(text)Return text in bold.
bold_tail(text, *[, sep])Put bold emphasis on the last part of a
foo.bar.bazstring.carp(s, **kwargs)Print something to stdout (or use
file=stderrkwargs).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 defcommand 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.Workerto execute this command.parse(argv)Parse command-line arguments in
argvand 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])Print something to stdout (or use
file=stderrkwarg).table(data[, title])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)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.Workerinstance for this command.Attributes Documentation
- abstract: ClassVar[bool] = False¶
- blocking_timeout¶
Return the blocking timeout used for this command.
- builtin_options: OptionSequence = [<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: bool = False¶
- loglevel¶
Return the log level used for this command.
- options: Optional[OptionList] = (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: str = ''¶
- redirect_stdouts: Optional[bool] = None¶
- redirect_stdouts_level: Optional[int] = None¶
- require_app = True¶
Methods Documentation
- __call__(*args: Any, **kwargs: Any) NoReturn¶
Call command-line command.
This will raise
SystemExitbefore 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.originis the package where the app is defined, so if this isexamples.simpleit 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: AbstractEventLoop, *args: Any, **kwargs: Any) ServiceT¶
Wrap command in a
mode.Serviceobject.
- 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.bazstring.
- carp(s: Any, **kwargs: Any) None¶
Print something to stdout (or use
file=stderrkwargs).- Note:
Does not do anything if the
--debugoption 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.
- async execute(*args: Any, **kwargs: Any) Any¶
Execute command.
- classmethod from_handler(*options: Any, **kwargs: Any) Callable[[Callable], Type[AppCommand]]¶
Decorate
async defcommand to create command class.
- import_relative_to_app(attr: str) Any¶
Import string like “module.Model”, or “Model” to model class.
- async on_stop() None¶
Call after command executed.
- on_worker_created(worker: Worker) None¶
Call when creating
faust.Workerto execute this command.
- classmethod parse(argv: Sequence[str]) Mapping¶
Parse command-line arguments in
argvand return mapping.
- async run(frequency: float, max_messages: int) None¶
Produce messages for the aggregation example.
- run_using_worker(*args: Any, **kwargs: Any) NoReturn¶
Execute command using
faust.Worker.
- say(message: str, file: Optional[IO] = None, err: Optional[IO] = None, **kwargs: Any) None¶
Print something to stdout (or use
file=stderrkwarg).- Note:
Does not do anything if the
--quietoption is enabled.
- table(data: Sequence[Sequence[str]], title: str = '', **kwargs: Any) BaseTable¶
Format table data as ANSI/ASCII table.
- tabulate(data: Sequence[Sequence[str]], headers: Optional[Sequence[str]] = None, wrap_last_row: bool = True, title: str = '', title_color: str = 'blue', **kwargs: Any) str¶
Create an ANSI representation of a table of two-row tuples.
- See Also:
Keyword arguments are forwarded to
terminaltables.SingleTable- Note:
If the
--jsonoption 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_serializerto set the codec for the key (e.g."json"), as set by the--key-serializeroption.
- to_model(typ: Optional[str], value: str, serializer: Optional[Union[CodecT, str]]) 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, andvalue_serializer.- Notes:
Uses
value_serializerto set the codec for the value (e.g."json"), as set by the--value-serializeroption.
- 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_serializerto set the codec for the value (e.g."json"), as set by the--value-serializeroption.
- worker_for_service(service: ServiceT, loop: Optional[AbstractEventLoop] = None) Worker¶
Create
faust.Workerinstance for this command.