make_record

kafkaaggregator.models.make_record(cls_name: str, fields: List[kafkaaggregator.fields.Field], doc: str = None) → faust_avro.record.Record

Create a Faust-avro Record subclass.

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 subclass.

Return type:

faust_avro.Record

Examples

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