:py:mod:`EVECelery.utils.ErrorLimiter` ====================================== .. py:module:: EVECelery.utils.ErrorLimiter Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: EVECelery.utils.ErrorLimiter.ErrorLimiter EVECelery.utils.ErrorLimiter.ESIErrorLimiter .. py:class:: ErrorLimiter Bases: :py:obj:`object` .. py:method:: max_remaining_errors() -> int :classmethod: Return the remaining error limit threshold. If the remaining error count is less than or equal to this value then ErrorLimitExceeded exceptions are raised. :return: Errors remaining allowed before raising ErrorLimitExceeded exceptions. .. py:method:: default_error_limit_remain() -> int :classmethod: :abstractmethod: Returns the default error limit remaining if the Redis key is created before being set by headers. :return: The default error limit remaining .. py:method:: default_error_limit_reset() -> int :classmethod: :abstractmethod: Returns the default reset internal in seconds if the Redis key is created before being set by headers. :return: The default reset interval in seconds. .. py:method:: get_key() -> str :classmethod: :abstractmethod: Returns the Redis key name for storing error information. :return: Redis key name :rtype: str .. py:method:: get_lock_key() -> str :classmethod: Returns the lock Redis key name for storing lock information. :return: Redis key name :rtype: str .. py:method:: get_redis(redis: redis.Redis) :classmethod: Return the data from Redis for the ErrorLimit key. :param redis: The redis client :return: Error limit information or None if not set. :rtype: dict or None .. py:method:: _create_default_limit(redis: redis.Redis) :classmethod: Set the default error info if the key does not exist in Redis. This class does not establish a lock. This function should only be used by calling functions with the lock obtained. :param redis: The redis client :return: None .. py:method:: check_limit(redis: redis.Redis) :classmethod: Ensure the remaining error limit is not breached. :param redis: The redis client :return: None :raises EVECelery.exceptions.utils.ErrorLimitExceeded: If the remaining error limit is below the allowed threshold. .. py:method:: update_limit(redis: redis.Redis, error_limit_remain: int, error_limit_reset: int, time: datetime.datetime) :classmethod: Updates the remaining error limit. :param redis: The redis client :param error_limit_remain: The error limit remaining. :param error_limit_reset: The error limit reset in seconds. :param time: The date time from the return header. :return: None .. py:method:: decrement_limit(redis: redis.Redis, time: datetime.datetime) :classmethod: Decrement the remaining error limit by one. Useful in timeout or missing header situations. :param redis: The redis client :param time: The date time from the calling function. :return: None .. py:class:: ESIErrorLimiter Bases: :py:obj:`ErrorLimiter` .. py:method:: default_error_limit_remain() :classmethod: Returns the default error limit remaining if the Redis key is created before being set by headers. :return: The default error limit remaining .. py:method:: default_error_limit_reset() -> int :classmethod: Returns the default reset internal in seconds if the Redis key is created before being set by headers. :return: The default reset interval in seconds. .. py:method:: get_key() :classmethod: Returns the Redis key name for storing error information. :return: Redis key name :rtype: str .. py:method:: max_remaining_errors() -> int :classmethod: Return the remaining error limit threshold. If the remaining error count is less than or equal to this value then ErrorLimitExceeded exceptions are raised. :return: Errors remaining allowed before raising ErrorLimitExceeded exceptions.