Allow plugin support for custom compression/decompression (e.g. zstd)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Ambito
- backend-api-design
Direzione di ricerca
Leggi http/src/main/scala/org/apache/pekko/http/scaladsl/coding/, concentrandoti su Coder, Compressor, StreamDecoder e Coders.DefaultCoders, quindi esamina la Java coding API. Definisci i punti di estensione supportati e il comportamento di negoziazione per i coder personalizzati in entrambi i DSLs. Il lavoro sarà considerato completato quando sarà disponibile un design dell’API concordato, insieme a test di implementazione e documentazione per la registrazione e l’utilizzo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature request: Plug-in support for custom compression (e.g., zstd) in Pekko HTTP coding subsystem
Context
Currently, Pekko HTTP provides built-in support for gzip (and deflate) compression via the Coder abstraction in org.apache.pekko.http.scaladsl.coding. This is used via encodeResponse, decodeRequest, and related directives, and the negotiation machinery is well-established. There is frequent interest (e.g., for modern formats like zstd) in supporting custom content encoding algorithms. Users may want to plug in their own encoders/decoders without modifying Pekko HTTP core code.
There is #860 which is about adding built-in support for zstd but it might be worth considering allowing the addition of custom compression/decompression so users can add support themselves.
Analysis
After reviewing the codebase (scaladsl/coding), here's what enables and what currently blocks custom compressions:
What works:
Coderis a marker trait (trait Coder extends Encoder with Decoder). Users can implement it today to support new encodings, e.g., zstd.HttpEncoding.custom(...)allows defining new encoding tokens, such aszstd.- Directives (
encodeResponseWith,decodeRequestWith) accept arbitraryEncoder/Decoders, so user-provided implementations can already be injected explicitly per-route.
Current barriers:
- Compressor and StreamDecoder are Internal/Deprecated:
Compressor(needed for encoding) andStreamDecoder(for decoding) are@InternalApiand@deprecated. ImplementingEncoder/Decoderneeds usage of these, but they're not public API and may change or disappear, so user-providers can't rely on them.
- Java API is closed:
- The Java-side equivalent (
org.apache.pekko.http.javadsl.coding.Coder) is a closedenum—Java users cannot add custom encoders at all.
- The Java-side equivalent (
- Default coders are fixed:
Coders.DefaultCodersis always[Gzip, Deflate, NoCoding]. There is no mechanism for registering a custom coder with the negotiation machinery globally. So, while you can use your custom coder per-route with theWithdirectives, it won't be automatically used with default directives.
Example: How it could work (after stabilising APIs)
object ZstdCoder extends Coder with StreamDecoder {
val encoding: HttpEncoding = HttpEncoding.custom("zstd")
def messageFilter = Encoder.DefaultFilter
private[this] def newCompressor = new ZstdCompressor() // if Compressor is public
def newDecompressorStage(maxBytesPerChunk: Int) = () => new ZstdDecompressorStage(maxBytesPerChunk)
}
// Usage:
encodeResponseWith(ZstdCoder, Coders.Gzip, Coders.Deflate, Coders.NoCoding) { ... }
decodeRequestWith(ZstdCoder, Coders.Gzip, Coders.Deflate) { ... }
Proposed Enhancements
- Promote Compressor and StreamDecoder to Public API:
- Remove
@InternalApiand@deprecatedfrom these types - Alternatively, provide a new public API for plugging in custom encoder/decoder flows
- Remove
- Open up Java API for Custom Coders:
- Replace or supplement the hardcoded
Coderenum with an interface/factory-based mechanism in the Java DSL
- Replace or supplement the hardcoded
- Make DefaultCoders Configurable or Injectable:
- Allow applications to register additional coders (e.g., via ActorSystem config or a registration method) for use by the default directives/negotiator
- (Optional) Add zstd as a built-in or contrib module:
- To showcase extensibility and provide instant value
- (Docs) Add a guide for implementing and registering custom coders
Impact
- This would unlock modern and/or domain-specific compression for Pekko HTTP users
- Immediate benefit for projects that need zstd or other algorithms (Brotli, LZ4, etc.)
- Makes Pekko HTTP encoding/decoding as extensible as its routing layers
If maintainers agree, I'm happy to help with API stabilisation PRs or further design discussion!
Origin: https://github.com/apache/pekko-http (discussion/analysis by pjfanning)
- Lingua principale
- Scala
- Stelle
- 196
- Fork
- 56
- Merge medio
- 1g 18h
- PR unite (30g)
- 43
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/pekko-http
-
dependencies
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
apache/pekko-http#1354 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
apache/pekko-http#1273 ·
I maintainer di solito rispondono entro 1 giorno
-
HTTP/2 client ALPN fallback needs a handshake-complete signal that the TLS stage does not emitAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
apache/pekko-http#1249 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
apache/pekko-http#1248 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
apache/pekko-http#1180 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/pekko-http
Issue simili
-
area:scale audit priority:P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
KD5UJC-XYZ/scarab#231 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUILD] Bump Ivy up to 2.6.0Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
[Bug Report] BOOM v4 with nBreakpoints>0 fails to elaborate in bpwatchSourceNode bulk connectAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
riscv-boom/riscv-boom#819 ·