linotp.lib.remote_service module

exception linotp.lib.remote_service.AllServicesUnavailable

Bases: Exception

Thrown when all services are unavailable.

This exception will be passed on to callers of RemoteService.call_first_available when there are no functional services left.

class linotp.lib.remote_service.RemoteService(func, failure_threshold=5, recovery_timeout=30, expected_exception=<class 'Exception'>)

Bases: object

A service that keeps track of it failures and marks itself as unavilable after an exceeding amount of configured (base) exceptions.

on_failure()
on_recovery()
class linotp.lib.remote_service.RemoteServiceList(failure_threshold=5, recovery_timeout=30, expected_exception=<class 'Exception'>)

Bases: list

A list of services that will transparently failover to the next service if one failes.

append(func, **kwargs)

Append object to the end of the list.

call_first_available(*args, **kwargs)

calls the first available service with the supplied arguments.

Raises

AllServicesUnavailable – If no service is available at the moment

exception linotp.lib.remote_service.ServiceUnavailable

Bases: Exception

Thrown when a service is unavailable.

This exception is used for failover to other services and not passed to users.

class linotp.lib.remote_service.State

Bases: object

State of a Service

FUNCTIONAL = 1
UNAVAILABLE = 2
linotp.lib.remote_service.now()

Return the current time.

This function is required for datetime mocking during testing.