News for hackers. Stuff that matters.
Re:Colossus: A New Service Framework from Tumblr by amelius on Tuesday November 18, 2014 @10:30AM (#8624231)
This sounds very useful.

One further question. Say a service A calls service B. And let's say service B needs several seconds to complete, and emits a progress indicator every second (I assume this is possible?) Will A be able to read these progress indicators also every second, and send its own progress indicator to its caller?

Re:Colossus: A New Service Framework from Tumblr by tekacs on Tuesday November 18, 2014 @10:52AM (#8624381)
It depends on the case, but an easy way to emit progress indicators in our system is to make the long-running service a generator. It looks like this:

    g = wym('/email') #=> Generator(id=<...>)
    g.on('value', (v) ->
        ...
    )
and /email looks like:

    function next(inp) { ... }
    return generator(next);
Sending values in uses a slightly different syntax, and manually walks the generator through. :)

A more trivial way is to pass in a callback for the service (we call them routes) to send its updates back to, but this requires more code to send values in.

Edit: to be clear, using a Generator as above isn't very microservice-ey and will trigger our framework to start tracking local state to keep the generator around, which it will auto-free when it believes it can. This is a necessary evil with any long-running code, though. Better is to break up the code so that it may be called multiple times to progress state and returning generator('/someRoute') if possible. :P