Example #1
0
    def ping(request):
        """Test that storage is operationnal.

        :param request: current request object
        :type request: :class:`~pyramid:pyramid.request.Request`
        :returns: ``True`` is everything is ok, ``False`` otherwise.
        :rtype: bool
        """
        try:
            auth = request.headers.get('Authorization')
            if asbool(request.registry.settings.get('readonly')):
                # Do not try to write in readonly mode.
                backend.get_all(_HEARTBEAT_COLLECTION_ID, _HEART_PARENT_ID,
                                auth=auth)
            else:
                if random.random() < _HEARTBEAT_DELETE_RATE:
                    backend.delete_all(_HEARTBEAT_COLLECTION_ID,
                                       _HEART_PARENT_ID, auth=auth)
                else:
                    backend.create(_HEARTBEAT_COLLECTION_ID, _HEART_PARENT_ID,
                                   _HEARTBEAT_RECORD, auth=auth)
            return True
        except:
            logger.exception("Heartbeat Error")
            return False
Example #2
0
    def ping(request):
        """Test that storage is operationnal.

        :param request: current request object
        :type request: :class:`~pyramid:pyramid.request.Request`
        :returns: ``True`` is everything is ok, ``False`` otherwise.
        :rtype: bool
        """
        try:
            auth = request.headers.get('Authorization')
            if asbool(request.registry.settings.get('readonly')):
                # Do not try to write in readonly mode.
                backend.get_all(_HEARTBEAT_COLLECTION_ID,
                                _HEART_PARENT_ID,
                                auth=auth)
            else:
                if random.random() < _HEARTBEAT_DELETE_RATE:
                    backend.delete_all(_HEARTBEAT_COLLECTION_ID,
                                       _HEART_PARENT_ID,
                                       auth=auth)
                else:
                    backend.create(_HEARTBEAT_COLLECTION_ID,
                                   _HEART_PARENT_ID,
                                   _HEARTBEAT_RECORD,
                                   auth=auth)
            return True
        except:
            logger.exception("Heartbeat Error")
            return False
Example #3
0
    def ping(request):
        """Test that cache backend is operationnal.

        :param request: current request object
        :type request: :class:`~pyramid:pyramid.request.Request`
        :returns: ``True`` is everything is ok, ``False`` otherwise.
        :rtype: bool
        """
        # No specific case for readonly mode because the cache should
        # continue to work in that mode.
        try:
            if random.random() < _HEARTBEAT_DELETE_RATE:
                backend.delete(_HEARTBEAT_KEY)
            else:
                backend.set(_HEARTBEAT_KEY, 'alive', _HEARTBEAT_TTL_SECONDS)
            return True
        except:
            logger.exception("Heartbeat Failure")
            return False
Example #4
0
    def ping(request):
        """Test that cache backend is operationnal.

        :param request: current request object
        :type request: :class:`~pyramid:pyramid.request.Request`
        :returns: ``True`` is everything is ok, ``False`` otherwise.
        :rtype: bool
        """
        # No specific case for readonly mode because the cache should
        # continue to work in that mode.
        try:
            if random.random() < _HEARTBEAT_DELETE_RATE:
                backend.delete(_HEARTBEAT_KEY)
            else:
                backend.set(_HEARTBEAT_KEY, 'alive', _HEARTBEAT_TTL_SECONDS)
            return True
        except:
            logger.exception("Heartbeat Failure")
            return False
Example #5
0
    def ping(request):
        """Test the permission backend is operationnal.

        :param request: current request object
        :type request: :class:`~pyramid:pyramid.request.Request`
        :returns: ``True`` is everything is ok, ``False`` otherwise.
        :rtype: bool
        """
        try:
            if asbool(request.registry.settings.get('readonly')):
                # Do not try to write in readonly mode.
                backend.get_user_principals(__HEARTBEAT_KEY__)
            else:
                backend.add_user_principal(__HEARTBEAT_KEY__, 'alive')
                backend.remove_user_principal(__HEARTBEAT_KEY__, 'alive')
        except:
            logger.exception("Heartbeat Error")
            return False
        return True
Example #6
0
    def ping(request):
        """Test the permission backend is operationnal.

        :param request: current request object
        :type request: :class:`~pyramid:pyramid.request.Request`
        :returns: ``True`` is everything is ok, ``False`` otherwise.
        :rtype: bool
        """
        try:
            if asbool(request.registry.settings.get('readonly')):
                # Do not try to write in readonly mode.
                backend.get_user_principals(__HEARTBEAT_KEY__)
            else:
                backend.add_user_principal(__HEARTBEAT_KEY__, 'alive')
                backend.remove_user_principal(__HEARTBEAT_KEY__, 'alive')
        except:
            logger.exception("Heartbeat Error")
            return False
        return True