package com.stand.standapp.net

import okhttp3.OkHttpClient
import java.util.concurrent.TimeUnit

object NetworkModule {
    private const val DEFAULT_CONNECT_TIMEOUT_SEC = 15L
    private const val DEFAULT_READ_TIMEOUT_SEC = 30L
    private const val DEFAULT_WRITE_TIMEOUT_SEC = 30L

    val defaultClient: OkHttpClient by lazy {
        OkHttpClient.Builder()
            .connectTimeout(DEFAULT_CONNECT_TIMEOUT_SEC, TimeUnit.SECONDS)
            .readTimeout(DEFAULT_READ_TIMEOUT_SEC, TimeUnit.SECONDS)
            .writeTimeout(DEFAULT_WRITE_TIMEOUT_SEC, TimeUnit.SECONDS)
            .retryOnConnectionFailure(true)
            .build()
    }

    fun streamingClient(): OkHttpClient {
        return defaultClient.newBuilder()
            .readTimeout(0, TimeUnit.MILLISECONDS)
            .build()
    }
}
