Hi! I'm newbie in coroutines. I'm wondering how I ...
# coroutines
d
Hi! I'm newbie in coroutines. I'm wondering how I can make Spring's RestTemplate work with coroutines? I'm going to check ktor's source code. But from my perspective, network intercation in RestTemplate is blocking and there will be no improvement with coroutines. Am I right?
e
nope, you should run it on IO pool
d
Sorry, didn't get it. Run RestTemplate on IO pool?
e
yes, you wrap a blocking call with IO context and use it in your coroutines
👍 1
d
Oh, thank you. Will try find some info on this.
e
Copy code
withContext(<http://Dispatchers.IO|Dispatchers.IO>){
    .. your blocking code
}
👍 1
d
Thank you so much!
k
also look at this: https://github.com/konrad-kaminski/spring-kotlin-coroutine Unless you're using Spring-Fu, Spring doesn't have built-in coroutine support