Provide a "minimal" version of makeDefaultOptions for libraries
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza con el protocolo HTTPClient y su API makeDefaultOptions existente; después, revisa cómo se definen los protocolos RequestOptions y las implementaciones concretas de clientes en esta propuesta. Compara los comportamientos mínimos y recomendados propuestos, y considera el issue completo solo cuando se hayan acordado y documentado la forma de la API y la semántica de las funcionalidades predeterminadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Swift
- Estrellas
- 70
- Forks
- 24
- Merge medio
- 9 h 31 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apple/swift-http-api-proposal
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
apple/swift-http-api-proposal#185 ·
-
Add `HTTPVersion` typePosiblemente ocupada @ehaydenr la tomó hace 64 días. Abiertokind/feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apple/swift-http-api-proposal#180 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
apple/swift-http-api-proposal#186 · 3 comentarios ·
-
http-server status/needs-design
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
apple/swift-http-api-proposal#182 · 1 comentario ·
-
kind/feature
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
apple/swift-http-api-proposal#179 ·
Todos los issues de apple/swift-http-api-proposal
Issues similares
-
Seed a JRNYAx price before the last close so asset-detail S1.3 doesn't fail from 08:00Z to the openAbiertobug tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
lognorman20/monaco#7231 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Provenance-Emu/SkinKit#42 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lwouis/alt-tab-macos#6154 ·
-
bug mac アプリ: コード アプリ: チャット 優先: 中 要トリアージ
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
yksr-melt/Meltype#1346 · 2 comentarios ·
Los mantenedores suelen responder en 1 día