`buildSequence(::getThingBlocking).forEach { ... }...
# announcements
k
buildSequence(::getThingBlocking).forEach { ... }
z
mm the
while(true)
is basically the core of the application, its only purpose is to do something with
thing
and then to get another
thing
.
k
Well the code I just posted does exactly the same as yours.
z
Copy code
buildSequence<String>({ client.blpop("somekey", "0") })
        .forEach { job -> logger.debug { "New job received: $job" } }
I've never used coroutines before. After the first call the process dies. Why?
Copy code
buildSequence<String>({
        while (true)
            client.blpop("somekey", "0").forEach { yield(it) }
    })
        .forEach { job ->
            logger.debug { "New job received: $job" }
        }
This works
k
Yup, forgot to put
yield
around it.
Actually
generateSequence
would be better.
z
Copy code
generateSequence { client.blpop("key", "0")[1] }.forEach { println(it) }
Wow
k
Nice!