intelligentplant / AppStoreConnect.Adapters

Allows Intelligent Plant App Store Connect to query 3rd party systems
https://appstore.intelligentplant.com
MIT License
0 stars 0 forks source link

Allow customisation of compression/decompression of raw key/value store values #368

Closed wazzamatazz closed 7 months ago

wazzamatazz commented 7 months ago

This PR adds protected virtual methods to RawKeyValueStore<T> that are called when compressing/decompressing raw values. It also adds IsGzipped methods to KeyValueStore that look for the gzip magic bytes (0x1F, 0x8B) at the start of an array or stream.

The purpose of these changes is to allow for situations where a RawKeyValueStore<T> implementation retrieves bytes from an external source that may not be compressed. RawKeyValueStore<T> always assumes that raw byte values being read from the store are compressed, since it always compresses bytes when they are written to the store. However, if an implementation received raw bytes from an external service and those raw bytes were not compressed, an exception would previously be thrown when the RawKeyValueStore<T> attempted to decompress the raw bytes.

The PR also makes minor changes to the FASTER key/value store size tracking used in metrics.