CollecTor Remotes

Remote CollecTor instance interaction.

This module provides tools for interacting with remote CollecTor instances, such as those run by Tor Metrics or 3rd-party public or private CollecTor instances.

bushel.collector.remote.DEFAULT_COLLECTOR_HOST

The default CollecTor host to use when none is specified, currently collector.torproject.org although this is subject to change. It will be set to the currently recommended public Tor Metrics instance.

bushel.collector.remote.DEFAULT_INDEX_COMPRESSION

The default compression algorithm used with CollecTor indexes. This is currently set to xz although is subject to change in line with any recommendations from Tor Metrics.

class bushel.collector.remote.CollecTorRemote(host: Optional[str] = None, *, https: bool = True)[source]

A remote CollecTor instance. Methods are provided for querying the data available on the remote instance, as well as retrieving data from the remote instance.

Parameters:
  • host (str) – The FQDN of the CollecTor instance. If None, then the DEFAULT_COLLECTOR_HOST is used.
  • https (bool) – Whether HTTPS should be used. This defaults to True.
get_index(compression: Optional[bushel.collector.filesystem.CollecTorIndexCompression]) → bushel.collector.index.CollecTorIndex[source]

Fetch the index from the CollecTor instance, optionally specifying the compression algorithm to use. This function will return an object that contains the (decompressed if necessary) and parsed index.

Parameters:compression (CollecTorIndexCompression) – Compression algorithm to use. If None, the default specified in DEFAULT_INDEX_COMPRESSION will be used.
Return type:CollecTorIndex
get_raw_by_path(path: str) → bytes[source]

Fetch the raw bytes of a file from a CollecTor instance.

Parameters:path (str) – CollecTor path with no leading slash (/).
Return type:bytes
Returns:Raw bytes of the reply, which may be compressed depending on the requested path.
bushel.collector.remote.get_index(host: Optional[str] = None, compression: Optional[bushel.collector.filesystem.CollecTorIndexCompression] = None, *, https: bool = True) → bushel.collector.index.CollecTorIndex[source]

Convenience function for CollecTorRemote(host, https=https).get_index(compression).