Hey Folks, we are running an nice little spring-b...
# coroutines
d
Hey Folks, we are running an nice little spring-boot webflux service in Kotlin. To brigde between coroutines and the webflux world, we use org.jetbrains.kotlinx:kotlinx-coroutines-reactor. As you can see in this little example, I switch the context in the controller.
Copy code
@RestController
class PageController(
    private val pageService: PageService,
) {
    private val context = <http://Dispatchers.IO|Dispatchers.IO>

    @GetMapping(PAGES_BY_SLUG)
    suspend fun getPage(
        @PathVariable slug: String,
    ): PageResponse = 
        withContext(context) { pageService.getPage(slug) }
   }

}
My motivation is to keep the webflux threadpool clean from everything that does not relate to the request till it reaches the controller. But does really have an positiv affect on performance? Or does the context switch here is even bad because it comes with an cost?
k
You're doing the same thing as you'd do with Reactor so no difference
d
What do you mean? I switch context to
Copy code
<http://Dispatchers.IO|Dispatchers.IO>