Skip to content

Composing distributed Web applications

Alberto edited this page Jun 30, 2016 · 8 revisions

Transient is a haskell library that allows the creation of Cloud and Web applications that can be composed to create more complex ones.

This is an example using the library transient that combines two cloud applications using the <|> operator:

 main =  keep $ do
   port <- getPort
   initWebApp port $  mapReduce <|>  chat <|>  addNode

It also combines a third console application for adding nodes.

The first is a distributed map-reduce app that get a text input from the user, distribute it among the server nodes and count the frequencies of words. The other is a federated chat, with N server nodes.

Each one of these apps has his own Web interface, that appears as a widget in the composed application. Many simultaneous users can make use of both widgets. It is a web application after all.

Each one of the two snippets including everything is about 20 lines of code.

The code run both in the browser and server. atRemote executes the argument in the server. clustered executes the argument in all the server nodes connected. MailBoxes communicate processes in the same node.

Both applications are made out of composable components as well.

[This video] (https://www.livecoding.tv/agocorona/videos/M5axK-testing-webcloud-computing-library-2/) shows everything running. It is livecoding so it may be slow and boring, sorry.

To install the full transient stack see the readme an do:

> ./buildrun.sh examples/distributedApps.hs
> ./examples/distributedApps

References:

Clone this wiki locally