Exporter

class resilient_exporters.exporters.Exporter(transform: Optional[Callable] = None, timeout: int = 30, use_memory: bool = True, manual_reexport: bool = True, *, tmp_file: Optional[Union[str, pathlib.Path, BinaryIO]] = None, reinitialize_tmp_file: bool = True, save_unsent_data: bool = True, name: Optional[str] = None, test_url: Optional[str] = None)[source]

Base class of all exporters and ExporterPool. It includes a non- implemented send function that its children must implement. It has abc.ABCMeta as a metaclass to enforce the implementation of send by all the children classes.

TEST_URL: Optional[str] = None

The URL to use to test a connection. If None, the URL will be “https://www.google.com”.

property use_memory

The value use_memory of the instance.

When set to True, it loads the data into memory if it was previously using a file (previous value was False), or vice versa.

Parameters

new_val (bool) – new value for use_memory.

Returns

its value

Return type

bool

transform(data: Any) → Any[source]

Applies transform to the given data.

Parameters

data (Any) – the data to pass to transform.

Returns

the output of transform

Return type

Any

Raises

Exception – if the output of transform(data) is None.

save_unsent_data(data: Any, kwargs: dict, exporter_name: str) → None[source]

Saves the data in memory or disk, depending on the value of use_memory of the instance, so it can be sent later.

Parameters
  • data (Any) – the core data.

  • kwargs (dict) – the keyword arguments to pass to send for the given data.

  • exporter_name (str) – the name of the exporter.

Returns

None

has_unsent_data() → bool[source]

Assesses if there’s saved, unsent data.

Returns

True if there’s saved, unsent data. False otherwise.

Return type

bool

send_unsent_data() → List[resilient_exporters.exporters.ExportResult][source]

Tries to send the previously saved, unsent data.

Returns

list of the results of the export jobs.

Return type

List[ExportResult]

abstract send(data, **kwargs) → Union[resilient_exporters.exporters.ExportResult, List[resilient_exporters.exporters.ExportResult]][source]

Abstract method to be implemented by children.

Raises

NotImplementedError