on master help sign in
WIP: add graph operator to remote functionality
commit78a58e024e5156e26f37e6f82d84e4d3f5cb21b9 authorAgentM <agentm@themactionfaction.com> dateSun 15 Nov 2015, 23:26 (11 years ago) parent4819b42
5 files changed+18−6
ProjectM36/Client.hs+3 ProjectM36/Daemon/EntryPoints.hs+6−3 ProjectM36/Daemon/Main.hs+3−2 ProjectM36/Daemon/RemoteCallTypes.hs+2 ProjectM36/TransactionGraph.hs+4−1
ProjectM36/Client.hs+3
@@ -202,6 +202,9 @@ executeGraphExpr (InProcessConnection strat tvar) graphExpr = do
202202 --this should really grab a lock at the beginning of the method to be threadsafe
203203 processPersistence strat newGraph
204204 return Nothing
205+executeGraphExpr (RemoteProcessConnection localNode serverProcessId) graphExpr = do
206+ runProcessResult localNode $ do
207+ call serverProcessId (ExecuteGraphExpr graphExpr)
205208
206209commit :: Connection -> IO (Maybe RelationalError)
207210commit conn = executeGraphExpr conn Commit
ProjectM36/Daemon/EntryPoints.hs+6−3
@@ -23,6 +23,9 @@ handleExecuteHeadName conn = do
2323 reply ret conn
2424
2525handleLogin :: Connection -> Process (ProcessReply Bool Connection)
26−handleLogin conn = do
27− reply True conn
28−
26+handleLogin conn = reply True conn
27+
28+handleExecuteGraphExpr :: Connection -> TransactionGraphOperator -> Process (ProcessReply (Maybe RelationalError) Connection)
29+handleExecuteGraphExpr conn graphExpr = do
30+ ret <- liftIO $ executeGraphExpr conn graphExpr
31+ reply ret conn
ProjectM36/Daemon/Main.hs+3−2
@@ -1,7 +1,7 @@
11{-# LANGUAGE ScopedTypeVariables #-}
22import ProjectM36.Client
33import ProjectM36.Daemon.ParseArgs (parseConfig, persistenceStrategy, databaseName)
4−import ProjectM36.Daemon.EntryPoints (handleExecuteRelationalExpr, handleExecuteDatabaseContextExpr, handleLogin, handleExecuteHeadName)
4+import ProjectM36.Daemon.EntryPoints (handleExecuteRelationalExpr, handleExecuteDatabaseContextExpr, handleLogin, handleExecuteHeadName, handleExecuteGraphExpr)
55import ProjectM36.Daemon.RemoteCallTypes (RemoteExecution(..))
66
77import System.Exit (exitFailure, exitSuccess)
@@ -21,7 +21,8 @@ serverDefinition = defaultProcess {
2121 apiHandlers = [handleCall (\conn Login -> handleLogin conn),
2222 handleCall (\conn ExecuteHeadName -> handleExecuteHeadName conn),
2323 handleCall (\conn (ExecuteRelationalExpr expr) -> handleExecuteRelationalExpr conn expr),
24− handleCall (\conn (ExecuteDatabaseContextExpr expr) -> handleExecuteDatabaseContextExpr conn expr)
24+ handleCall (\conn (ExecuteDatabaseContextExpr expr) -> handleExecuteDatabaseContextExpr conn expr),
25+ handleCall (\conn (ExecuteGraphExpr expr) -> handleExecuteGraphExpr conn expr)
2526 ],
2627 unhandledMessagePolicy = Log
2728 }
ProjectM36/Daemon/RemoteCallTypes.hs+2
@@ -1,6 +1,7 @@
11{-# LANGUAGE DeriveAnyClass, DeriveGeneric #-}
22module ProjectM36.Daemon.RemoteCallTypes where
33import ProjectM36.Base
4+import ProjectM36.TransactionGraph
45import GHC.Generics
56import Data.Binary
67
@@ -8,5 +9,6 @@ data RemoteExecution = Login |
89 Logout |
910 ExecuteRelationalExpr RelationalExpr |
1011 ExecuteDatabaseContextExpr DatabaseExpr |
12+ ExecuteGraphExpr TransactionGraphOperator |
1113 ExecuteHeadName
1214 deriving (Binary, Generic)
ProjectM36/TransactionGraph.hs+4−1
@@ -1,4 +1,4 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings, DeriveAnyClass, DeriveGeneric #-}
22module ProjectM36.TransactionGraph where
33import ProjectM36.Base
44import ProjectM36.Error
@@ -14,6 +14,8 @@ import qualified Data.Set as S
1414import qualified Data.Map as M
1515import Control.Monad
1616import qualified Data.Text as T
17+import GHC.Generics
18+import Data.Binary
1719
1820--operators which manipulate a transaction graph
1921data TransactionGraphOperator = JumpToHead HeadName |
@@ -21,6 +23,7 @@ data TransactionGraphOperator = JumpToHead HeadName |
2123 Branch HeadName |
2224 Commit |
2325 Rollback
26+ deriving (Eq, Show, Binary, Generic)
2427
2528data ROTransactionGraphOperator = ShowGraph
2629