Skip to content

Latest commit

 

History

History
82 lines (67 loc) · 6.47 KB

compression.md

File metadata and controls

82 lines (67 loc) · 6.47 KB

Compression implementation

This document connects the compression specification to the implementation in this repository. It is informative: deviations recorded here do not weaken the generic contract.

Public API

Request compression is configured with RequestCompressionAlgorithm and minCompressionSizeBytes in AlternatorConfig. Response compression is configured with ResponseCompressionAlgorithm.

Both client builders propagate these settings and install the corresponding execution interceptors.

Internal architecture

GzipRequestInterceptor reads and caches serialized request bytes, decides whether the threshold is met, and provides a replacement blocking or asynchronous body.

ResponseCompressionInterceptor adds Accept-Encoding, recognizes configured response encodings, strips stale response headers, and wraps blocking streams or asynchronous publishers for decompression.

Lifecycle and concurrency

Compression runs in the request and response interceptor lifecycle. Request bodies are buffered before compression. Asynchronous responses are also buffered completely, then emitted as one decoded buffer after positive demand. Per-request execution attributes hold cached request bytes, the request compression decision, and the selected response encoding.

Requirement mapping

Requirement Code Test evidence Status
COMP-REQ-001 AlternatorConfig FeatureSpecDefaultsTest#compressionDefaultsMatchSpecification conformant
COMP-REQ-002 GzipRequestInterceptor GzipRequestInterceptorTest#testCompressedBodyIsValidGzip gap
COMP-REQ-003 GzipRequestInterceptor — gap
COMP-REQ-004 ResponseCompressionInterceptor ResponseCompressionInterceptorTest#testGzipSyncResponseIsDecompressedAndHeadersAreStripped gap
COMP-REQ-005 ResponseCompressionInterceptor — gap
COMP-REQ-006 ResponseCompressionInterceptor ResponseCompressionInterceptorTest#testGzipAsyncResponseIsDecompressedAndHeadersAreStripped gap
COMP-REQ-007 AlternatorDynamoDbClient AlternatorConfigHeadersTest#testHeadersOptimizationWithCompression gap
COMP-REQ-008 AlternatorDynamoDbAsyncClient ResponseCompressionIT#testAsyncSdkClientParsesGzipResponse gap

Test coverage

Known conformance gaps

  • COMP-REQ-002, COMP-REQ-003, COMP-REQ-007, COMP-REQ-008: The request-compression interceptor is not conformant in the current request pipeline. Content modifiers run before modifyHttpRequest(...), but the interceptor reads the body and records its decision only in modifyHttpRequest(...). An ordinary eligible request therefore carries Content-Encoding: gzip with its original JSON bytes. Existing tests call these methods in the opposite order and integration tests inspect the header without validating the transmitted gzip stream.
  • COMP-REQ-002: A replacement body does not update the original Content-Length, and a present zero-byte body is compressed when the threshold is zero.
  • COMP-REQ-003: Compressor failure returns original bytes after the gzip header decision instead of failing or removing that header. No injected compressor-failure test covers the path.
  • COMP-REQ-004: The selected response encoding is stored in request-scoped attributes and is not cleared for a later unencoded, unsupported, or ambiguous retry response. A stale encoding can be reused across attempts.
  • COMP-REQ-005, COMP-REQ-006, COMP-REQ-008: Corrupt configured responses, asynchronous demand accounting, non-positive demand, upstream errors, cancellation, case and parameter handling, duplicate algorithms, and multiple encoding header values lack direct coverage.