Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/base.py
# Copyright (C) 2016-2018 The Software Heritage developers | # Copyright (C) 2016-2018 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 abc | import abc | ||||
import io | import io | ||||
import logging | import logging | ||||
import traceback | import traceback | ||||
from typing import ClassVar, Set | from typing import ClassVar, Set | ||||
from psycopg2.extensions import QueryCanceledError | from psycopg2.extensions import QueryCanceledError | ||||
import sentry_sdk | import sentry_sdk | ||||
import swh.model.swhids | |||||
from swh.model.swhids import CoreSWHID, ObjectType | from swh.model.swhids import CoreSWHID, ObjectType | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
MAX_BUNDLE_SIZE = 2**29 # 512 MiB | MAX_BUNDLE_SIZE = 2**29 # 512 MiB | ||||
DEFAULT_CONFIG_PATH = "vault/cooker" | DEFAULT_CONFIG_PATH = "vault/cooker" | ||||
DEFAULT_CONFIG = { | DEFAULT_CONFIG = { | ||||
"max_bundle_size": ("int", MAX_BUNDLE_SIZE), | "max_bundle_size": ("int", MAX_BUNDLE_SIZE), | ||||
} | } | ||||
Show All 33 Lines | class BaseVaultCooker(metaclass=abc.ABCMeta): | ||||
This class describes a common API for the cookers. | This class describes a common API for the cookers. | ||||
To define a new cooker, inherit from this class and override: | To define a new cooker, inherit from this class and override: | ||||
- CACHE_TYPE_KEY: key to use for the bundle to reference in cache | - CACHE_TYPE_KEY: key to use for the bundle to reference in cache | ||||
- def cook(): cook the object into a bundle | - def cook(): cook the object into a bundle | ||||
""" | """ | ||||
SUPPORTED_OBJECT_TYPES: ClassVar[Set[ObjectType]] | SUPPORTED_OBJECT_TYPES: ClassVar[Set[swh.model.swhids.ObjectType]] | ||||
BUNDLE_TYPE: ClassVar[str] | BUNDLE_TYPE: ClassVar[str] | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
swhid: CoreSWHID, | swhid: CoreSWHID, | ||||
backend, | backend, | ||||
storage: StorageInterface, | storage: StorageInterface, | ||||
graph=None, | graph=None, | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |