Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/objstorage.py
Show All 27 Lines | class ObjStorage(metaclass=abc.ABCMeta): | ||||
Conceptually, the object storage offers the following methods: | Conceptually, the object storage offers the following methods: | ||||
- check_config() check if the object storage is properly configured | - check_config() check if the object storage is properly configured | ||||
- __contains__() check if an object is present, by object id | - __contains__() check if an object is present, by object id | ||||
- add() add a new object, returning an object id | - add() add a new object, returning an object id | ||||
- restore() same as add() but erase an already existed content | - restore() same as add() but erase an already existed content | ||||
- get() retrieve the content of an object, by object id | - get() retrieve the content of an object, by object id | ||||
- check() check the integrity of an object, by object id | - check() check the integrity of an object, by object id | ||||
- delete() remove an object | |||||
And some management methods: | And some management methods: | ||||
- get_random() get random object id of existing contents (used for the | - get_random() get random object id of existing contents (used for the | ||||
content integrity checker). | content integrity checker). | ||||
Some of the methods have available streaming equivalents: | Some of the methods have available streaming equivalents: | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | def check(self, obj_id, *args, **kwargs): | ||||
Raises: | Raises: | ||||
ObjNotFoundError: if the requested object is missing. | ObjNotFoundError: if the requested object is missing. | ||||
Error: if the request object is corrupted. | Error: if the request object is corrupted. | ||||
""" | """ | ||||
pass | pass | ||||
@abc.abstractmethod | |||||
def delete(self, obj_id, *args, **kwargs): | |||||
"""Delete an object. | |||||
Args: | |||||
obj_id (bytes): object identifier. | |||||
Raises: | |||||
ObjNotFoundError: if the requested object is missing. | |||||
""" | |||||
pass | |||||
# Management methods | # Management methods | ||||
def get_random(self, batch_size, *args, **kwargs): | def get_random(self, batch_size, *args, **kwargs): | ||||
"""Get random ids of existing contents. | """Get random ids of existing contents. | ||||
This method is used in order to get random ids to perform | This method is used in order to get random ids to perform | ||||
content integrity verifications on random contents. | content integrity verifications on random contents. | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |