Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/retry.py
# Copyright (C) 2019-2020 The Software Heritage developers | # Copyright (C) 2019-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
import traceback | import traceback | ||||
from datetime import datetime | from datetime import datetime | ||||
from typing import Dict, Iterable, List, Optional, Union | from typing import Any, Dict, Iterable, Optional, Union | ||||
from tenacity import ( | from tenacity import ( | ||||
retry, | retry, | ||||
stop_after_attempt, | stop_after_attempt, | ||||
wait_random_exponential, | wait_random_exponential, | ||||
) | ) | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | def origin_visit_update( | ||||
metadata: Optional[Dict] = None, | metadata: Optional[Dict] = None, | ||||
snapshot: Optional[Dict] = None, | snapshot: Optional[Dict] = None, | ||||
) -> Dict: | ) -> Dict: | ||||
return self.storage.origin_visit_update( | return self.storage.origin_visit_update( | ||||
origin, visit_id, status=status, metadata=metadata, snapshot=snapshot | origin, visit_id, status=status, metadata=metadata, snapshot=snapshot | ||||
) | ) | ||||
@swh_retry | @swh_retry | ||||
def tool_add(self, tools: Iterable[Dict]) -> List[Dict]: | def metadata_fetcher_add( | ||||
tools = list(tools) | self, name: str, version: str, metadata: Dict[str, Any] | ||||
return self.storage.tool_add(tools) | ) -> None: | ||||
return self.storage.metadata_fetcher_add(name, version, metadata) | |||||
@swh_retry | @swh_retry | ||||
def metadata_provider_add( | def metadata_authority_add( | ||||
self, provider_name: str, provider_type: str, provider_url: str, metadata: Dict | self, type: str, url: str, metadata: Dict[str, Any] | ||||
) -> Union[str, int]: | ) -> None: | ||||
return self.storage.metadata_provider_add( | return self.storage.metadata_authority_add(type, url, metadata) | ||||
provider_name, provider_type, provider_url, metadata | |||||
) | |||||
@swh_retry | @swh_retry | ||||
def origin_metadata_add( | def origin_metadata_add( | ||||
self, | self, | ||||
origin_url: str, | origin_url: str, | ||||
ts: Union[str, datetime], | discovery_date: datetime, | ||||
provider_id: int, | authority: Dict[str, Any], | ||||
tool_id: int, | fetcher: Dict[str, Any], | ||||
metadata: Dict, | format: str, | ||||
metadata: bytes, | |||||
) -> None: | ) -> None: | ||||
return self.storage.origin_metadata_add( | return self.storage.origin_metadata_add( | ||||
origin_url, ts, provider_id, tool_id, metadata | origin_url, discovery_date, authority, fetcher, format, metadata | ||||
) | ) | ||||
@swh_retry | @swh_retry | ||||
def directory_add(self, directories: Iterable[Directory]) -> Dict: | def directory_add(self, directories: Iterable[Directory]) -> Dict: | ||||
return self.storage.directory_add(directories) | return self.storage.directory_add(directories) | ||||
@swh_retry | @swh_retry | ||||
def revision_add(self, revisions: Iterable[Revision]) -> Dict: | def revision_add(self, revisions: Iterable[Revision]) -> Dict: | ||||
Show All 18 Lines |