zostay / RakuWAPI

The Web API for Raku (RakuWAPI)
Artistic License 2.0
24 stars 5 forks source link

Consider moving the Promise from application to server #13

Closed zostay closed 9 years ago

zostay commented 9 years ago

One issue I have with making the application keeper of the Promise is that the application is not guaranteed to be synchronous and might do something stupid:

sub app(%env) {
    my @result = do-really-long-running-thing();
    Promise.new(:@result);
}

This potentially locks the server/middleware when it might otherwise expect an immediate return. Also, there is an argument to made for allowing the server the opportunity to perform synchronous work within a single thread rather than having to use 2 threads.

So, consider the utility of just making the application return whenever it feels like, but let the server worry about how to deal with a long-running application.

zostay commented 9 years ago

I have decided to keep the Promise in the application. I have added an admonition to Layer 2 that the application return control back to the server as soon as possible on each request. I might still renege on this or even regret it, but it feels like the right way to go.