hmole
01/13/2019, 2:09 PMThreadLocal.asContextElement
? Currenlty I use retrofit with CompletableFuture
futures and then using async
extension function from jdr8 integration package. But the request itself is executed in OkHttp own thread pool and so my ThreadLocal
is null there, since coroutine doesn't know about this thread.Call<T>
and then wrap blocking get
into async
it works as expected.Dico
01/13/2019, 6:14 PMgildor
01/14/2019, 6:40 AMhmole
01/14/2019, 6:45 AMval serviceCode = async { api.serviceCode().execute().body()!!
}
val tracked = async { api.trackedObjects().execute().body()!!
}
No specific use case, I just want to use Retrofit and Coroutines. Ideally without using special CallFactory and relying on jdk8 Future
and then turning it into Deferred
.gildor
01/14/2019, 8:09 AMCompletableFuture.await()
extension functionhmole
01/14/2019, 11:10 AMCallAwait
I will have the same problem, because it calls enqueue
on OkHttp threadpool.
I put user authentication in coroutinecontext to make requests to other services(ktor server) so it can be accessed inside an Interceptor that put's it into header for each request that's executed in said context.