nkiesel
12/02/2020, 11:00 PMprivate const val TIME_OUT = 10000 // in milliseconds
private val config = RequestConfig.custom()
.setConnectTimeout(TIME_OUT)
.setConnectionRequestTimeout(TIME_OUT)
.setSocketTimeout(TIME_OUT)
.build()
I only need TIME_OUT
for this initialization. How can I avoid having it hanging around? One idea I had was
private val config = 10_000.let { timeOut ->
RequestConfig.custom()
.setConnectTimeout(timeOut)
.setConnectionRequestTimeout(timeOut)
.setSocketTimeout(timeOut)
.build()
}
but that is not pretty either. Are there better ways?Nir
12/02/2020, 11:03 PMNir
12/02/2020, 11:03 PMNir
12/02/2020, 11:04 PMprivate val config = run {
const val TIME_OUT = 10000
RequestConfig.custom()
.setConnectTimeout(TIME_OUT)
.setConnectionRequestTimeout(TIME_OUT)
.setSocketTimeout(TIME_OUT)
.build()
}
Chris Ruddell
12/02/2020, 11:04 PMNir
12/02/2020, 11:05 PMnkiesel
12/02/2020, 11:18 PMrun
looks better than my let
. Thx!Nir
12/02/2020, 11:20 PMNir
12/02/2020, 11:21 PMnkiesel
12/02/2020, 11:28 PMbuildList
James Richardson
12/03/2020, 8:37 AMJames Richardson
12/03/2020, 8:39 AMnkiesel
12/03/2020, 7:11 PM10.seconds.toLongNanoSeconds()
and it is a mockup service, so 10 seconds for everything is ok here. I share your overall view on what is important, but really was just trying to improve my low-level coding toolset here.