swh.storage.buffer module

class swh.storage.buffer.BufferingProxyStorage(storage: Mapping, min_batch_size: Mapping = {})[source]

Bases: object

Storage implementation in charge of accumulating objects prior to

discussing with the “main” storage.

Deduplicates values based on a tuple of keys depending on the object type.

Sample configuration use case for buffering storage:

  cls: buffer
      cls: remote
      args: http://storage.internal.staging.swh.network:5002/
      content: 10000
      content_bytes: 100000000
      skipped_content: 10000
      directory: 5000
      revision: 1000
      release: 10000
content_add(contents: Collection[swh.model.model.Content]) → Dict[source]

Push contents to write to the storage in the buffer.

Following policies apply:
  • if the buffer’s threshold is hit, flush content to the storage.

  • otherwise, if the total size of buffered contents’s threshold is hit,

flush content to the storage.

skipped_content_add(contents: Collection[swh.model.model.SkippedContent]) → Dict[source]
object_add(objects: Collection[swh.model.model.BaseModel], *, object_type: str, keys: Iterable[str]) → Dict[str, int][source]

Push objects to write to the storage in the buffer. Flushes the buffer to the storage if the threshold is hit.

flush(object_types: Optional[List[str]] = None) → Dict[str, int][source]
clear_buffers(object_types: Optional[List[str]] = None) → None[source]

Clear objects from current buffer.


data that has not been flushed to storage will be lost when this method is called. This should only be called when flush fails and you want to continue your processing.