create_record

kafkaaggregator.models.create_record(cls_name: str, fields: List[Field], doc: Optional[str] = None) Record

Create a Faust-avro Record class during runtime.

Parameters:
  • cls_name (str) – Name of the new class to create.

  • fields (list [Field]) – List of tuples mapping field names and types for the Faust-avro Record.

  • doc (str) – Docstring for the new class.

Returns:

cls – A faust_avro.Record class.

Return type:

Record

Examples

>>> from kafkaaggregator.fields import Field
>>> from kafkaaggregator.models import create_record
>>> Foo = create_record('Foo', [Field('bar', int)])
>>> f = Foo(bar=0)
>>> f.bar
0
>>> f.dumps()
{'bar': 0, '__faust': {'ns': '__main__.Foo'}}