# -*- coding: utf-8 -*-"""Implements :class:`SimpleConsumer`, a file-based consumer for local developmentand testing."""importdataclassesfrompathlibimportPathfromitertoolsimportislicefromfunc_args.apiimportREQfrom..abstractionimportAbcRecordfrom..checkpointimportT_POINTER,BaseCheckPointfrom..consumerimportBaseConsumer
[docs]@dataclasses.dataclassclassSimpleConsumer(BaseConsumer):""" A simple consumer that read data from a local, append-only log file. It is a good example to show how to implement a consumer and understand the behavior of the consumer. You should use it along with :class:`~unistream.producers.simple.SimpleProducer`. .. note:: Don't initialize this class directly, use the :meth:`SimpleConsumer.new` method :param record_class: the record class. :param limit: the max number of records to fetch from the stream system. :param checkpoint: the :class:`~unistream.checkpoint.BaseCheckpoint` object for status tracking and fault tolerance. :param exp_backoff_multiplier: the multiplier of the exponential backoff :param exp_backoff_base: the base of the exponential backoff :param exp_backoff_min: the minimum wait time of the exponential backoff :param exp_backoff_max: the maximum wait time of the exponential backoff :param skip_error: if True, skip the error and continue to process the next record. this is the most common use case. if False, raise the error and stop the consumer. :param delay: the delay time between pulling two batches. :param path_source: the path of the source file to read from. :param path_dlq: the path of the dead letter queue file to write to. """path_source:Path=dataclasses.field(default=REQ)path_dlq:Path=dataclasses.field(default=REQ)