Ejemplo n.º 1
0
def build_response(rid):
    from sdh.curator.actions import get_instance
    response_class = r.hget('requests:{}'.format(rid), '__response_class')
    if response_class is None:
        raise AttributeError('Cannot create a response for {}'.format(rid))
    (module_name, class_name) = tuple(response_class.split('.'))
    return get_instance(module_name, class_name, rid)
Ejemplo n.º 2
0
def used_channels():
    req_channel_keys = r.keys('requests:*')
    for rck in req_channel_keys:
        try:
            channel = r.hget(rck, 'channel')
            yield channel
        except Exception as e:
            log.warning(e.message)
Ejemplo n.º 3
0
 def remove(self):
     with r.pipeline(transaction=True) as p:
         p.multi()
         action_id = r.hget(self._request_key, 'id')
         p.zrem('requests', action_id)
         r_keys = r.keys('{}*'.format(self._request_key))
         for key in r_keys:
             p.delete(key)
         self._remove(p)
         p.execute()
     log.info('Request {} was removed'.format(self._request_id))
Ejemplo n.º 4
0
 def _remove(self, pipe):
     super(DeliverySink, self)._remove(pipe)
     pipe.srem('deliveries', self._request_id)
     pipe.srem('deliveries:ready', self._request_id)
     channel_b64 = r.hget(self._request_key, 'channel')
     sharing = channel_sharing(channel_b64)
     if not sharing:
         log.info('Removing delivery channel ({}) for request {}'.format(channel_b64, self._request_id))
         pipe.delete('channels:{}'.format(channel_b64))
     else:
         log.info('Cannot remove delivery channel of request {}. It is being shared with {} another requests'.format(
             self.request_id, sharing))
Ejemplo n.º 5
0
 def stream(self):
     return parse_bool(r.hget('requests:{}'.format(self._request_id), '__stream'))
Ejemplo n.º 6
0
 def _remove(self, pipe):
     self._fragment_id = r.hget('{}'.format(self._request_key), 'fragment_id')
     pipe.srem('fragments:{}:requests'.format(self._fragment_id), self._request_id)
     super(FragmentSink, self)._remove(pipe)
Ejemplo n.º 7
0
 def delivery(self):
     return r.hget('requests:{}'.format(self._request_id), 'delivery')