EVECelery.utils.ErrorLimiter#

Module Contents#

Classes#

ErrorLimiter

ESIErrorLimiter

class EVECelery.utils.ErrorLimiter.ErrorLimiter#

Bases: object

classmethod max_remaining_errors() int#

Return the remaining error limit threshold. If the remaining error count is less than or equal to this value then ErrorLimitExceeded exceptions are raised.

Returns:

Errors remaining allowed before raising ErrorLimitExceeded exceptions.

Return type:

int

abstract classmethod default_error_limit_remain() int#

Returns the default error limit remaining if the Redis key is created before being set by headers.

Returns:

The default error limit remaining

Return type:

int

abstract classmethod default_error_limit_reset() int#

Returns the default reset internal in seconds if the Redis key is created before being set by headers.

Returns:

The default reset interval in seconds.

Return type:

int

abstract classmethod get_key() str#

Returns the Redis key name for storing error information.

Returns:

Redis key name

Return type:

str

classmethod get_lock_key() str#

Returns the lock Redis key name for storing lock information.

Returns:

Redis key name

Return type:

str

classmethod get_redis(redis: redis.Redis)#

Return the data from Redis for the ErrorLimit key.

Parameters:

redis (redis.Redis) – The redis client

Returns:

Error limit information or None if not set.

Return type:

dict or None

classmethod _create_default_limit(redis: redis.Redis)#

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.

Parameters:

redis (redis.Redis) – The redis client

Returns:

None

classmethod check_limit(redis: redis.Redis)#

Ensure the remaining error limit is not breached.

Parameters:

redis (redis.Redis) – The redis client

Returns:

None

Raises:

EVECelery.exceptions.utils.ErrorLimitExceeded – If the remaining error limit is below the allowed threshold.

classmethod update_limit(redis: redis.Redis, error_limit_remain: int, error_limit_reset: int, time: datetime.datetime)#

Updates the remaining error limit.

Parameters:
  • redis (redis.Redis) – The redis client

  • error_limit_remain (int) – The error limit remaining.

  • error_limit_reset (int) – The error limit reset in seconds.

  • time (datetime.datetime) – The date time from the return header.

Returns:

None

classmethod decrement_limit(redis: redis.Redis, time: datetime.datetime)#

Decrement the remaining error limit by one. Useful in timeout or missing header situations.

Parameters:
  • redis (redis.Redis) – The redis client

  • time (datetime.datetime) – The date time from the calling function.

Returns:

None

class EVECelery.utils.ErrorLimiter.ESIErrorLimiter#

Bases: ErrorLimiter

classmethod default_error_limit_remain()#

Returns the default error limit remaining if the Redis key is created before being set by headers.

Returns:

The default error limit remaining

classmethod default_error_limit_reset() int#

Returns the default reset internal in seconds if the Redis key is created before being set by headers.

Returns:

The default reset interval in seconds.

Return type:

int

classmethod get_key()#

Returns the Redis key name for storing error information.

Returns:

Redis key name

Return type:

str

classmethod max_remaining_errors() int#

Return the remaining error limit threshold. If the remaining error count is less than or equal to this value then ErrorLimitExceeded exceptions are raised.

Returns:

Errors remaining allowed before raising ErrorLimitExceeded exceptions.

Return type:

int