git.iko.soy/distributed-process
on master help sign in
Add comments from the docs to the demos
ecb51c1Edsko de Vries
distributed-process-azure/demos/Echo.hs+10−1
@@ -29,12 +29,21 @@ main :: IO ()
29main = do
29main = do
30 args <- getArgs
30 args <- getArgs
31 case args of
31 case args of
32+ "onvm":args' ->
33+ -- Pass execution to 'onVmMain' if we are running on the VM
34+ -- ('callOnVM' will provide the right arguments)
32− "onvm":args' -> onVmMain __remoteTable args'
35+ onVmMain __remoteTable args'
36+
33 sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
37 sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
38+ -- Initialize the Azure backend
34 params <- defaultAzureParameters sid x509 pkey
39 params <- defaultAzureParameters sid x509 pkey
35 let params' = params { azureSshUserName = user }
40 let params' = params { azureSshUserName = user }
36 backend <- initializeBackend params' cloudService
41 backend <- initializeBackend params' cloudService
42+
43+ -- Find the specified virtual machine
37 Just vm <- findNamedVM backend virtualMachine
44 Just vm <- findNamedVM backend virtualMachine
45+
46+ -- Run the echo client proper
38 callOnVM backend vm port $
47 callOnVM backend vm port $
39 ProcessPair ($(mkClosure 'echoRemote) ())
48 ProcessPair ($(mkClosure 'echoRemote) ())
40 echoLocal
49 echoLocal
distributed-process-azure/demos/Ping.hs+11−1
@@ -55,16 +55,26 @@ main :: IO ()
55main = do
55main = do
56 args <- getArgs
56 args <- getArgs
57 case args of
57 case args of
58+ "onvm":args' ->
59+ -- Pass execution to 'onVmMain' if we are running on the VM
58− "onvm":args' -> onVmMain __remoteTable args'
60+ onVmMain __remoteTable args'
61+
59 "list":sid:x509:pkey:_ -> do
62 "list":sid:x509:pkey:_ -> do
63+ -- List all available cloud services
64+ -- (useful, but not strictly necessary for the example)
60 params <- defaultAzureParameters sid x509 pkey
65 params <- defaultAzureParameters sid x509 pkey
61 css <- cloudServices (azureSetup params)
66 css <- cloudServices (azureSetup params)
62 mapM_ print css
67 mapM_ print css
68+
63 cmd:sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
69 cmd:sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
70+ -- Initialize the backend and find the right VM
64 params <- defaultAzureParameters sid x509 pkey
71 params <- defaultAzureParameters sid x509 pkey
65 let params' = params { azureSshUserName = user }
72 let params' = params { azureSshUserName = user }
66 backend <- initializeBackend params' cloudService
73 backend <- initializeBackend params' cloudService
67 Just vm <- findNamedVM backend virtualMachine
74 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
68 case cmd of
78 case cmd of
69 "server" -> spawnOnVM backend vm port ($(mkClosure 'pingServer) ())
79 "server" -> spawnOnVM backend vm port ($(mkClosure 'pingServer) ())
70 "client" -> callOnVM backend vm port $
80 "client" -> callOnVM backend vm port $