Provide a "minimal" version of makeDefaultOptions for libraries
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con il protocollo HTTPClient e la sua API makeDefaultOptions esistente, quindi esamina come sono definiti in questa proposta i protocolli RequestOptions e le implementazioni concrete dei client. Confronta i comportamenti minimo e consigliato proposti e considera conclusa l’issue solo quando la forma dell’API e la semantica delle funzionalità predefinite saranno concordate e documentate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I think we need a "minimal" variant of makeDefaultOptions (the way to create new options from a library, when you don't know which concrete HTTP client implementation you're using). Because as a library, you can't afford to have the client arbitrarily choose to enable various features you're a) not aware of and b) aren't expecting. For example, if there's a "Batching" feature, represented by a protocol like:
protocol BatchingOptions: RequestOptions {
/// Defines the batch of body bytes that are filled up before being sent.
var batchSize: Int64?
}
This could be a useful optimization, but always needs to be opt-in. Either by you using a known concrete client, or you requesting that feature through the protocol constraint:
func makeAnHTTPCall<Client: HTTPClient>(client: Client) where Client.RequestOptions: BatchingOptions async throws {
var options = client.makeDefaultOptions()
options.batchSize = 4096
try await client.perform(request, options: options) {
}
}
However, if you don't request it, and your library looks like this:
func makeAnHTTPCall<Client: HTTPClient>(client: Client) async throws {
var options = client.makeDefaultOptions()
try await client.perform(request, options: options) {
}
}
Then client.makeDefaultOptions() absolutely must have batchSize = nil, otherwise the library won't work correctly with bidi streaming, as bytes will be held back until reaching the batch size, but the library has no way of learning or fixing that, without explicitly requiring that feature just to turn it off.
So if we assume that the set of options protocols will be open, and community libraries will be able to add additional ones, and the set of HTTP client implementations will also be an open set, it means that "default options" must mean "features disabled", and libraries will only enable those that they need by explicitly requesting that protocol and enabling them.
Now, some features are on/off, such as this batching example, and we can easily require that "default options" turns it off. However for other features that can't really negatively affect a library's observable behavior, we can still discuss what "on" vs "off" means. For example, I'd argue it's fine if the default value for "HTTP versions supported" is "all", even though some folks could consider that "on". Maybe that means we should re-spell that feature as "Subset of HTTP versions requested", so not allowing an HTTP version would be considered "on" for that feature.
This is why I think we need another variant of "default options" that makes it clear that it's not "nice-to-have, recommended options" (which is useful for applications, and can still exist e.g. under the name "recommended"), but must be "all features as disabled as they can be" (which is the only way to make behavior predictable to libraries, here called "minimal").
Maybe the simplest spelling that still allows this is:
protocol HTTPClient {
// associated types
func makeRecommendedOptions() -> RequestOptions
func makeMinimalOptions() -> RequestOptions
// perform method
}
So applications and concrete client utils would default to recommended, while libraries would always start with minimal (though I don't like the name, so please suggest a better one).
- Lingua principale
- Swift
- Stelle
- 70
- Fork
- 24
- Merge medio
- 9h 31m
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un 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 apple/swift-http-api-proposal
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
apple/swift-http-api-proposal#185 ·
-
Add `HTTPVersion` typeForse già presa @ehaydenr l’ha presa 59 giorni fa. Apertakind/feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apple/swift-http-api-proposal#180 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
apple/swift-http-api-proposal#186 · 3 commenti ·
-
http-server status/needs-design
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
apple/swift-http-api-proposal#182 · 1 commento ·
-
kind/feature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
apple/swift-http-api-proposal#179 ·
Tutte le issue di apple/swift-http-api-proposal
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
jellyfin/Swiftfin#2388 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
openclaw/openclaw#183929 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
area: browser area: cli
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
manaflow-ai/cmux#25105 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
glushchenko/fsnotes#2045 ·