Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Cloud a = Cloud {}
- runCloudIO :: Typeable a => Cloud a -> IO a
- runCloudIO' :: Typeable a => Cloud a -> IO a
- local :: Loggable a => TransIO a -> Cloud a
- onAll :: TransIO a -> Cloud a
- lazy :: TransIO a -> Cloud a
- loggedc :: Loggable a => Cloud a -> Cloud a
- lliftIO :: Loggable a => IO a -> Cloud a
- localIO :: Loggable a => IO a -> Cloud a
- listen :: Node -> Cloud ()
- connect :: Node -> Node -> Cloud ()
- connect' :: Node -> Cloud ()
- fullStop :: Cloud stop
- wormhole :: Loggable a => Node -> Cloud a -> Cloud a
- teleport :: Cloud ()
- copyData :: (Typeable * b, Read b, Show b) => b -> Cloud b
- beamTo :: Node -> Cloud ()
- forkTo :: Node -> Cloud ()
- streamFrom :: Loggable a => Node -> Cloud (StreamData a) -> Cloud (StreamData a)
- callTo :: Loggable a => Node -> Cloud a -> Cloud a
- runAt :: Loggable a => Node -> Cloud a -> Cloud a
- atRemote :: (Typeable * a, Read a, Show a) => Cloud a -> Cloud a
- clustered :: Loggable a => Cloud a -> Cloud a
- mclustered :: (Monoid a, Loggable a) => Cloud a -> Cloud a
- callNodes :: (Typeable * a1, Typeable * a, Read a1, Read a, Show a1, Show a) => (Cloud a1 -> Cloud a -> Cloud a) -> Cloud a -> Cloud a1 -> Cloud a
- newMailbox :: Text -> TransIO ()
- putMailbox :: Typeable a => Text -> a -> TransIO ()
- getMailbox :: Typeable * b => Text -> TransIO b
- cleanMailbox :: Typeable a => Text -> a -> TransIO ()
- single :: TransIO a -> TransIO a
- setBuffSize :: Int -> TransIO ()
- getBuffSize :: TransIO BuffSize
- createNode :: HostName -> Integer -> IO Node
- createWebNode :: IO Node
- createNodeServ :: HostName -> Integer -> [Service] -> IO Node
- getMyNode :: TransIO Node
- getNodes :: MonadIO m => m [Node]
- addNodes :: [Node] -> TransIO ()
- shuffleNodes :: MonadIO m => m [Node]
- getWebServerNode :: TransIO Node
- data Node = Node {
- nodeHost :: HostName
- nodePort :: Int
- connection :: MVar Pool
- nodeServices :: [Service]
- nodeList :: TVar [Node]
- data Connection = Connection {}
- type Service = (Package, Program)
- isBrowserInstance :: Bool
- newtype Prefix = Prefix JSString
- addPrefix :: TransIO ()
- defConnection :: MonadIO m => m Connection
Documentation
runCloudIO' :: Typeable a => Cloud a -> IO a Source #
run the cloud computation with no console input
onAll :: TransIO a -> Cloud a Source #
alternative to local
It means that if the computation is translated to other node
this will be executed again if this has not been executed inside a local
computation.
onAll foo local foo' local $ do bar runCloud $ do onAll baz runAt node .... callTo node' .....
Here foo will be executed in node' but foo' bar and baz don't.
However foo bar and baz will e executed in node.
connect :: Node -> Node -> Cloud () Source #
set the rest of the computation as a new node (first parameter) and connect it
to an existing node (second parameter). then it uses connect
` to synchronize the list of nodes
connect' :: Node -> Cloud () Source #
synchronize the list of nodes with a remote node and all the nodes connected to it the final effect is that all the nodes reachable share the same list of nodes
fullStop :: Cloud stop Source #
stop the current computation and does not execute any alternative computation
primitives for communication
wormhole :: Loggable a => Node -> Cloud a -> Cloud a Source #
A wormhole opens a connection with another node anywhere in a computation.
teleport
uses this connection to translate the computation back and forth between the two nodes connected
translates computations back and forth between two nodes
reusing a connection opened by wormhole
each teleport transport to the other node what is new in the log since the last teleport
It is used trough other primitives like runAt
which involves two teleports:
runAt node= wormhole node $ loggedc $ do > teleport > r <- Cloud $ runCloud proc <** setData WasRemote > teleport > return r
copyData :: (Typeable * b, Read b, Show b) => b -> Cloud b Source #
copy a session data variable from the local to the remote node. If there is none set in the local node, The parameter is the default value. In this case, the default value is also set in the local node.
single node invocation
beamTo :: Node -> Cloud () Source #
continue the execution in a new node
all the previous actions from listen
to this statement must have been logged
forkTo :: Node -> Cloud () Source #
execute in the remote node a process with the same execution state
streamFrom :: Loggable a => Node -> Cloud (StreamData a) -> Cloud (StreamData a) Source #
callTo
can stream data but can not inform the receiving process about the finalization. This call
does it.
callTo :: Loggable a => Node -> Cloud a -> Cloud a Source #
open a wormhole to another node and executes an action on it. currently by default it keep open the connection to receive additional requests and responses (streaming)
atRemote :: (Typeable * a, Read a, Show a) => Cloud a -> Cloud a Source #
Within an open connection to other node opened by wormhole
, it run the computation in the remote node and return
the result back to the original node.
invocation of many nodes
clustered :: Loggable a => Cloud a -> Cloud a Source #
execute a Transient action in each of the nodes connected.
The response of each node is received by the invoking node and processed by the rest of the procedure. By default, each response is processed in a new thread. To restrict the number of threads use the thread control primitives.
this snippet receive a message from each of the simulated nodes:
main = keep $ do let nodes= map createLocalNode [2000..2005] addNodes nodes (foldl (<|>) empty $ map listen nodes) <|> return () r <- clustered $ do Connection (Just(PortNumber port, _, _, _)) _ <- getSData return $ "hi from " ++ show port++ "\n" liftIO $ putStrLn r where createLocalNode n= createNode "localhost" (PortNumber n)
callNodes :: (Typeable * a1, Typeable * a, Read a1, Read a, Show a1, Show a) => (Cloud a1 -> Cloud a -> Cloud a) -> Cloud a -> Cloud a1 -> Cloud a Source #
messaging
newMailbox :: Text -> TransIO () Source #
getMailbox :: Typeable * b => Text -> TransIO b Source #
get messages from the mailbox that matches with the type expected.
The order of reading is defined by readTChan
This is reactive. it means that each new message trigger the execution of the continuation
each message wake up all the getMailbox
computations waiting for it.
cleanMailbox :: Typeable a => Text -> a -> TransIO () Source #
delete all subscriptions for that mailbox expecting this kind of data.
thread control
single :: TransIO a -> TransIO a Source #
execute a single thread for each connection
box <- foo r <- runAt node . local . single $ getMailbox box localIO $ print r
if foo would return many values, the above code would monitor one remote mailbox each time: the last one entered. Without single, it would monitor all of them.
setBuffSize :: Int -> TransIO () Source #
getBuffSize :: TransIO BuffSize Source #
node management
createWebNode :: IO Node Source #
shuffleNodes :: MonadIO m => m [Node] Source #
low level
Node | |
|
data Connection Source #
defConnection :: MonadIO m => m Connection Source #