git.iko.soy/distributed-process
on master help sign in
Add comments from the docs to the demos
commitecb51c1778bed87f080e523a2c6d936eac37a7f9 authorEdsko de Vries <edsko@well-typed.com> dateWed 22 Aug 2012, 09:06 (14 years ago) parent3b8e9f4
2 files changed+21−2
distributed-process-azure/demos/Echo.hs+10−1 distributed-process-azure/demos/Ping.hs+11−1
distributed-process-azure/demos/Echo.hs+10−1
@@ -29,12 +29,21 @@ main :: IO ()
2929main = do
3030 args <- getArgs
3131 case args of
32− "onvm":args' -> onVmMain __remoteTable args'
32+ "onvm":args' ->
33+ -- Pass execution to 'onVmMain' if we are running on the VM
34+ -- ('callOnVM' will provide the right arguments)
35+ onVmMain __remoteTable args'
36+
3337 sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
38+ -- Initialize the Azure backend
3439 params <- defaultAzureParameters sid x509 pkey
3540 let params' = params { azureSshUserName = user }
3641 backend <- initializeBackend params' cloudService
42+
43+ -- Find the specified virtual machine
3744 Just vm <- findNamedVM backend virtualMachine
45+
46+ -- Run the echo client proper
3847 callOnVM backend vm port $
3948 ProcessPair ($(mkClosure 'echoRemote) ())
4049 echoLocal
distributed-process-azure/demos/Ping.hs+11−1
@@ -55,16 +55,26 @@ main :: IO ()
5555main = do
5656 args <- getArgs
5757 case args of
58− "onvm":args' -> onVmMain __remoteTable args'
58+ "onvm":args' ->
59+ -- Pass execution to 'onVmMain' if we are running on the VM
60+ onVmMain __remoteTable args'
61+
5962 "list":sid:x509:pkey:_ -> do
63+ -- List all available cloud services
64+ -- (useful, but not strictly necessary for the example)
6065 params <- defaultAzureParameters sid x509 pkey
6166 css <- cloudServices (azureSetup params)
6267 mapM_ print css
68+
6369 cmd:sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
70+ -- Initialize the backend and find the right VM
6471 params <- defaultAzureParameters sid x509 pkey
6572 let params' = params { azureSshUserName = user }
6673 backend <- initializeBackend params' cloudService
6774 Just vm <- findNamedVM backend virtualMachine
75+
76+ -- The same binary can behave as the client or the server,
77+ -- depending on the command line arguments
6878 case cmd of
6979 "server" -> spawnOnVM backend vm port ($(mkClosure 'pingServer) ())
7080 "client" -> callOnVM backend vm port $