Exemplo n.º 1
0
 def service_id(self):
     try:
         return ServiceId(self._get_metadata_property('serviceId'))
     except UndefinedModelAttributeError:
         raise MissingServiceIdError(
             service_name=self._service_name
         )
Exemplo n.º 2
0
def register_retries_for_service(service_data, session,
                                 service_name, **kwargs):
    loader = session.get_component('data_loader')
    endpoint_prefix = service_data.get('metadata', {}).get('endpointPrefix')
    if endpoint_prefix is None:
        logger.debug("Not registering retry handlers, could not endpoint "
                     "prefix from model for service %s", service_name)
        return
    service_id = service_data.get('metadata', {}).get('serviceId')
    if service_id is None:
        raise MissingServiceIdError(service_name=service_name)
    service_event_name = hyphenize_service_id(service_id)
    config = _load_retry_config(loader, endpoint_prefix)
    if not config:
        return
    logger.debug("Registering retry handlers for service: %s", service_name)
    handler = retryhandler.create_retry_handler(
        config, endpoint_prefix)
    unique_id = 'retry-config-%s' % service_event_name
    session.register('needs-retry.%s' % service_event_name,
                     handler, unique_id=unique_id)
    _register_for_operations(config, session, service_event_name)