Foso / Ktorfit

HTTP client generator / KSP plugin for Kotlin Multiplatform (Android, iOS, Js, Jvm, Native, WasmJs)) using KSP and Ktor clients inspired by Retrofit https://foso.github.io/Ktorfit
https://foso.github.io/Ktorfit
Apache License 2.0
1.6k stars 43 forks source link

Allow for custom timeouts #723

Closed mandrachek closed 3 weeks ago

mandrachek commented 3 weeks ago

Is your feature request related to a problem? Please describe.

I have APIs that download and upload files. Sometimes these files are large and take quite some time for upload/download depending on the client's network connection.

Describe the solution you'd like

Add @RequestTimeout(timeout: Long) and @SocketTimeout(timeout: Long) annotations that allow setting longer timeouts for specific api calls. (Using these would require you have the HttpTimeout plugin installed.)

Describe alternatives you've considered

Additional context

No response

mandrachek commented 3 weeks ago

So, haha, it looks like this should be doable with @ReqBuilder, ala:

    @ReqBuilder builder: HttpRequestBuilder.() -> Unit = {
        timeout {
            requestTimeoutMillis = 60*60*1000
            socketTimeoutMillis = 60*60*1000
        }
    },