Create a generic continuation mechanism
The continuation system should be extended to support long polling in REST apis. Specifically, something like:
trait Continuation {
def await: Box[LiftResponse] // wait for the response of invoke the platform's continuation mechanism
}
object S {
def prepareContinuation(f: (Box[LiftResponse] => Nothing) => Unit): Continuation = ... build the continuation here
}
val continuation = S.prepareContinuation{
respondWith => ... create response
respondWith(response)
}
continuation.await
The begin method returns Box[LiftResponse]. If the app is running in a container without continuation support, continuation.begin blocks until the continuation is satisfied on the worker thread. If the container has continuation support, the request is suspended and resumed when the function (respondWith) is invoked.
trait Continuation {
def await: Box[LiftResponse] // wait for the response of invoke the platform's continuation mechanism
}
object S {
def prepareContinuation(f: (Box[LiftResponse] => Nothing) => Unit): Continuation = ... build the continuation here
}
val continuation = S.prepareContinuation{
respondWith => ... create response
respondWith(response)
}
continuation.await
The begin method returns Box[LiftResponse]. If the app is running in a container without continuation support, continuation.begin blocks until the continuation is satisfied on the worker thread. If the container has continuation support, the request is suspended and resumed when the function (respondWith) is invoked.
Leave a comment
Sounds cool ... I'm using Jetty 7 Continuations at work for REST API's ... but that's Java ... bleaaah.
Is the API you suggested nailed down? ... I'd still like to noodle a bit on it.
Is the API you suggested nailed down? ... I'd still like to noodle a bit on it.
Fixed.