https://kotlinlang.org logo
#http4k
Title
# http4k
m

mbonnin

10/06/2023, 3:17 PM
Is there an example of a websocket server that sends messages on its own schedule (not echoing an inbound message). Should I manage my own threadpool/coroutineScope to call
ws.send()
or is there some scope I can reuse?
d

dave

10/06/2023, 5:19 PM
Nope - you're on your own there, so just use which ever tech you want to manage the threads 🙃
m

mbonnin

10/06/2023, 5:22 PM
Would it make sense for http4k to manage that? I would expect jetty or any other application server to be opinionated about how to handle resources. Maybe the number of threads depend on the number of active websockets or can be pooled with HTTP or something like that?
d

dave

10/06/2023, 5:25 PM
It would be very tricky to make that work unless you could use the same thread resources to construct both the server layer and the handler. The design of http4k (and SaaF in general) means the runtime is an external (ie unknown) comcern to the handler. We'd lose any type of layering or composition if we did it.
👍 1
m

mbonnin

10/06/2023, 5:27 PM
Alright, fair enough 👍 It's not like I need to massively scale anyways... (for now 😄 )