Tommi Mäkitalo <tommi@...> writes:
> Am 09.03.2013 22:25, schrieb ArtemGr:
> I would really like to understand, how you do this asynchrounous thing.

Well, I have updated the
https://gist.github.com/ArtemGr/4248402
with the latest code and here is a simple example:
http://pastebin.com/ULiRPigH
It fetches some data (the Frople) from the ElasticSearch
(using a fault-tolerang `goUntil` wrapper around the asynchronous libevent's
http client; the wrapper is at http://code.google.com/p/libglim/)
and passes it into Ecpp template.

The practical value of this example is that ElasticSearch can be slow to respond
if one of the nodes is down, but everything will still work because we do
the ElasticSearch query asynchronously, not locking any threads while the
ElasticSearch is thinking.

> I just think about, what I would do different, when I would start from 
> scratch. It may be an option to re implement the kernel of tntnet if it 
> is a big win. The assumptions in http communication, which were true 10 
> years ago, when I started with tntnet are not all true today. 
> Asynchronous requests using websockets is one thing. Also this new 
> google http extension spdy changes the way a http server implementer has 
> to think about sockets. It was true, that one connection can handle 
> exactly one request in one time and hence can be bound to a single 
> thread. But it is not true with spdy. So a tntnet reboot may be an option.

WebSockets might be useful as a layer for something like
the Atmosphere framework (https://github.com/Atmosphere/atmosphere)
but, IMO, the real proven value of the asynchronous stack
is not being dependent on the response time of the underlying services
(databases, REST services, etc).
If you want some good practices, there is a Play Framework
http://www.playframework.com/documentation/2.1.0/ScalaAsync
There are good abstractions in Scalaz
http://docs.google.com/present/view?id=ddmk3f43_63zpg3jcgz
Servlet API 3 is an example of making a synchronous stack asynchronous
(Servlet 3 `suspend` == libevhtp `evhtp_request_pause`).


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to