swh.objstorage.backends.seaweed module

class swh.objstorage.backends.seaweed.WeedFiler(url)[source]

Bases: object

Simple class that encapsulates access to a seaweedfs filer service.

TODO: handle errors

get(remote_path)[source]
exists(remote_path)[source]
put(fp, remote_path)[source]
delete(remote_path)[source]
list(dir, last_file_name=None, limit=10000)[source]

list sub folders and files of @dir. show a better look if you turn on

returns a dict of “sub-folders and files”

class swh.objstorage.backends.seaweed.WeedObjStorage(url='http://127.0.0.1:8888/swh', compression=None, **kwargs)[source]

Bases: swh.objstorage.objstorage.ObjStorage

ObjStorage with seaweedfs abilities, using the Filer API.

https://github.com/chrislusf/seaweedfs/wiki/Filer-Server-API

check_config(*, check_write)[source]

Check the configuration for this object storage

add(content, obj_id=None, check_presence=True)[source]

Add a new object to the object storage.

Parameters
  • content (bytes) – object’s raw content to add in storage.

  • obj_id (bytes) – checksum of [bytes] using [ID_HASH_ALGO] algorithm. When given, obj_id will be trusted to match the bytes. If missing, obj_id will be computed on the fly.

  • check_presence (bool) – indicate if the presence of the content should be verified before adding the file.

Returns

the id (bytes) of the object into the storage.

restore(content, obj_id=None)[source]

Restore a content that have been corrupted.

This function is identical to add but does not check if the object id is already in the file system. The default implementation provided by the current class is suitable for most cases.

Parameters
  • content (bytes) – object’s raw content to add in storage

  • obj_id (bytes) – checksum of bytes as computed by ID_HASH_ALGO. When given, obj_id will be trusted to match bytes. If missing, obj_id will be computed on the fly.

get(obj_id)[source]

Retrieve the content of a given object.

Parameters

obj_id (bytes) – object id.

Returns

the content of the requested object as bytes.

Raises

ObjNotFoundError – if the requested object is missing.

check(obj_id)[source]

Perform an integrity check for a given object.

Verify that the file object is in place and that the content matches the object id.

Parameters

obj_id (bytes) – object identifier.

Raises
delete(obj_id)[source]

Delete an object.

Parameters

obj_id (bytes) – object identifier.

Raises

ObjNotFoundError – if the requested object is missing.

list_content(last_obj_id=None, limit=10000)[source]

Generates known object ids.

Parameters
  • last_obj_id (bytes) – object id from which to iterate from (excluded).

  • limit (int) – max number of object ids to generate.

Generates:

obj_id (bytes): object ids.