uv.reader package¶
Submodules¶
uv.reader.base module¶
The base AbstractReader class, along with all of the subclasses that AbstractReader is able to return from any of its methods.
-
class
uv.reader.base.AbstractReader[source]¶ Bases:
objectBase class for all classes that are able to track and return lists of metrics, keyed by a supplied t.MetricKey.
NOTE - by default, read_all and read are implemented in terms of one another. This means that you can choose which method you’d like to override, or override both… but if you don’t override any you’ll see infinite recursion.
Be careful not to abuse the kindness!
-
read(k: str) → List[Any][source]¶ Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.
-
read_all(ks: List[str]) → Dict[str, List[Any]][source]¶ Accepts a list of t.MetricKey instances and returns a mapping of t.MetricKey to a list of all metrics ever logged using that MetricKey.
The interface requires that the set of keys in the returned dictionary equal the input set; any missing key in the store has to map to a default empty list.
-
-
class
uv.reader.base.IterableReader[source]¶ Bases:
abc.ABCClass marker for Reader instances that are able to provide an iterable of all keys that it’s possible to read using this Reader instance.
-
class
uv.reader.base.PrefixedReader(base: uv.reader.base.AbstractReader, prefix: Union[str, List[str]])[source]¶ Bases:
uv.reader.base.AbstractReaderReader that prepends a prefix to all keys before passing requests on to the supplied backing store.
- Parameters
base – Backing reader. All read and read_all calls proxy here.
prefix – the prefix to attach to all keys supplied to any method.
-
read(k: str) → List[Any][source]¶ Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.
-
read_all(ks: List[str]) → Dict[str, List[Any]][source]¶ Accepts a list of t.MetricKey instances and returns a mapping of t.MetricKey to a list of all metrics ever logged using that MetricKey.
The interface requires that the set of keys in the returned dictionary equal the input set; any missing key in the store has to map to a default empty list.
-
class
uv.reader.base.SuffixedReader(base: uv.reader.base.AbstractReader, suffix: Union[str, List[str]])[source]¶ Bases:
uv.reader.base.AbstractReaderReader that prepends a suffix to all keys before passing requests on to the supplied backing store.
- Parameters
base – Backing reader. All read and read_all calls proxy here.
suffix – the suffix to attach to all keys supplied to any method.
-
read(k: str) → List[Any][source]¶ Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.
-
read_all(ks: List[str]) → Dict[str, List[Any]][source]¶ Accepts a list of t.MetricKey instances and returns a mapping of t.MetricKey to a list of all metrics ever logged using that MetricKey.
The interface requires that the set of keys in the returned dictionary equal the input set; any missing key in the store has to map to a default empty list.
uv.reader.store module¶
AbstractReader implementations that live at the bottom of the reader stack. These readers aren’t combinators; they’re responsible for returning stored values from some underlying store or mechanism.
-
class
uv.reader.store.EmptyReader[source]¶ Bases:
uv.reader.base.AbstractReader,uv.reader.base.IterableReaderAbstractReader that uses NO internal state. EmptyReader returns an empty list for every metric.
-
keys() → Iterable[str][source]¶ Returns an iterable of all keys that you’re able to query from this store.
-
read(k: str) → List[Any][source]¶ Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.
-
read_all(ks: List[str]) → Dict[str, List[Any]][source]¶ Accepts a list of t.MetricKey instances and returns a mapping of t.MetricKey to a list of all metrics ever logged using that MetricKey.
The interface requires that the set of keys in the returned dictionary equal the input set; any missing key in the store has to map to a default empty list.
-
-
class
uv.reader.store.LambdaReader(read: Optional[Callable[[str], List[Any]]] = None, read_all: Optional[Callable[[List[str]], Dict[str, List[Any]]]] = None, close: Optional[Callable[[], None]] = None)[source]¶ Bases:
uv.reader.base.AbstractReaderAbstractReader implementation that defers to a supplied lambda for its values. This allows you to escape the object-oriented programming paradigm, if you so choose.
- Parameters
read – Function called whenever reader.read(k) is called.
read_all – Function called whenever reader.read_all(ks) is called.
close – If supplied, this no-arg function will get called by this instance’s close method.
-
read(k: str) → List[Any][source]¶ Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.
-
read_all(ks: List[str]) → Dict[str, List[Any]][source]¶ Accepts a list of t.MetricKey instances and returns a mapping of t.MetricKey to a list of all metrics ever logged using that MetricKey.
The interface requires that the set of keys in the returned dictionary equal the input set; any missing key in the store has to map to a default empty list.
-
class
uv.reader.store.MemoryReader(m: Optional[Dict[str, List[Any]]])[source]¶ Bases:
uv.reader.base.AbstractReader,uv.reader.base.IterableReaderReader that queries the supplied dictionary for values.
- Parameters
m – Dictionary mapping metric keys to a list of accumulated metric values.
-
keys() → Iterable[Any][source]¶ Returns an iterable of all keys that you’re able to query from this store.
-
read(k: str) → List[Any][source]¶ Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.
-
read_all(ks: List[str]) → Dict[str, List[Any]][source]¶ Accepts a list of t.MetricKey instances and returns a mapping of t.MetricKey to a list of all metrics ever logged using that MetricKey.
The interface requires that the set of keys in the returned dictionary equal the input set; any missing key in the store has to map to a default empty list.