Commit 3b0f2595 authored by Mart Lubbers's avatar Mart Lubbers Committed by Haye Böhm

Add storing symbols to the engine

parent 8ec5b7ac
...@@ -99,8 +99,7 @@ getDomain ...@@ -99,8 +99,7 @@ getDomain
startMode :: String -> Task () startMode :: String -> Task ()
startMode executable startMode executable
= startDistributedEngine executable = get serverRoleShare
>>| get serverRoleShare
>>- \role = case role of >>- \role = case role of
DomainServer domain -> startAuthEngine domain >>| loginAndManageWorkList "Service engineer application" (myTasks True) DomainServer domain -> startAuthEngine domain >>| loginAndManageWorkList "Service engineer application" (myTasks True)
Server domain -> startAuthEngine domain >>| loginRemote (myTasks False) Server domain -> startAuthEngine domain >>| loginRemote (myTasks False)
...@@ -141,6 +140,6 @@ Start world ...@@ -141,6 +140,6 @@ Start world
= startEngineWithOptions opts [ publish "/" (\_-> startMode (IF_WINDOWS "examples.exe" "examples")) = startEngineWithOptions opts [ publish "/" (\_-> startMode (IF_WINDOWS "examples.exe" "examples"))
] world ] world
where where
opts [] = \op->(Just op, ["Started server on port: " +++ toString op.serverPort]) opts [] = \op->(Just {op&distributed=True}, ["Started server on port: " +++ toString op.serverPort])
opts ["-p",p:as] = appFst (fmap (\o->{o & serverPort=toInt p})) o opts as opts ["-p",p:as] = appFst (fmap (\o->{o & serverPort=toInt p})) o opts as
opts [a:as] = opts as opts [a:as] = opts as
...@@ -23,6 +23,7 @@ import iTasks.WF.Definition ...@@ -23,6 +23,7 @@ import iTasks.WF.Definition
, persistTasks :: Bool , persistTasks :: Bool
, autoLayout :: Bool , autoLayout :: Bool
, timeout :: Maybe Int // The timeout , timeout :: Maybe Int // The timeout
, distributed :: Bool
, webDirPath :: FilePath // Location of public files that are served by the iTask webserver , webDirPath :: FilePath // Location of public files that are served by the iTask webserver
, storeDirPath :: FilePath // Location of the application's persistent data files , storeDirPath :: FilePath // Location of the application's persistent data files
, tempDirPath :: FilePath // Location for temporary files used in tasks , tempDirPath :: FilePath // Location for temporary files used in tasks
......
...@@ -25,6 +25,7 @@ import iTasks.Internal.IWorld, iTasks.Internal.TaskEval, iTasks.Internal.TaskSto ...@@ -25,6 +25,7 @@ import iTasks.Internal.IWorld, iTasks.Internal.TaskEval, iTasks.Internal.TaskSto
import iTasks.Internal.Util import iTasks.Internal.Util
import iTasks.Internal.TaskServer import iTasks.Internal.TaskServer
import iTasks.Internal.EngineTasks import iTasks.Internal.EngineTasks
import iTasks.Internal.Distributed.Symbols
from iTasks.Extensions.DateTime import toDate, toTime, instance == Date, instance == Time from iTasks.Extensions.DateTime import toDate, toTime, instance == Date, instance == Time
...@@ -44,14 +45,23 @@ defaultEngineOptions world ...@@ -44,14 +45,23 @@ defaultEngineOptions world
# options = # options =
{ appName = appName { appName = appName
, appPath = appPath , appPath = appPath
, appVersion = appVersion , appVersion = appVersion
, serverPort = IF_POSIX_OR_WINDOWS 8080 80 , serverPort = IF_POSIX_OR_WINDOWS 8080 80
<<<<<<< HEAD
, serverUrl = "http://localhost/" , serverUrl = "http://localhost/"
, keepaliveTime = {tv_sec=300,tv_nsec=0} // 5 minutes , keepaliveTime = {tv_sec=300,tv_nsec=0} // 5 minutes
, sessionTime = {tv_sec=60,tv_nsec=0} // 1 minute, (the client pings every 10 seconds by default) , sessionTime = {tv_sec=60,tv_nsec=0} // 1 minute, (the client pings every 10 seconds by default)
, persistTasks = False , persistTasks = False
, autoLayout = True , autoLayout = True
, timeout = Just 500 , timeout = Just 500
=======
, serverUrl = "http://localhost/"
, keepaliveTime = 300 // 5 minutes
, sessionTime = 60 // 1 minute, (the client pings every 10 seconds by default)
, persistTasks = False
, autoLayout = True
, distributed = False
>>>>>>> Add storing symbols to the engine
, webDirPath = appDir </> appName +++ "-www" , webDirPath = appDir </> appName +++ "-www"
, storeDirPath = appDir </> appName +++ "-data" </> "stores" , storeDirPath = appDir </> appName +++ "-data" </> "stores"
, tempDirPath = appDir </> appName +++ "-data" </> "tmp" , tempDirPath = appDir </> appName +++ "-data" </> "tmp"
...@@ -133,6 +143,8 @@ startEngineWithOptions initFun publishable world ...@@ -133,6 +143,8 @@ startEngineWithOptions initFun publishable world
# iworld = createIWorld (fromJust mbOptions) world # iworld = createIWorld (fromJust mbOptions) world
# (res,iworld) = initJSCompilerState iworld # (res,iworld) = initJSCompilerState iworld
| res =:(Error _) = show ["Fatal error: " +++ fromError res] (destroyIWorld iworld) | res =:(Error _) = show ["Fatal error: " +++ fromError res] (destroyIWorld iworld)
# (_, iworld) = if options.distributed (storeSymbols options.appName iworld) (Ok "", iworld)
| res =:(Error _) = show ["Fatar error: " +++ fromError res] (destroyIWorld iworld)
# iworld = serve [TaskWrapper removeOutdatedSessions] (tcpTasks options.serverPort options.keepaliveTime) (timeout options.timeout) iworld # iworld = serve [TaskWrapper removeOutdatedSessions] (tcpTasks options.serverPort options.keepaliveTime) (timeout options.timeout) iworld
= destroyIWorld iworld = destroyIWorld iworld
where where
......
...@@ -10,7 +10,7 @@ import iTasks.Extensions.Distributed._Formatter ...@@ -10,7 +10,7 @@ import iTasks.Extensions.Distributed._Formatter
import iTasks.Extensions.Distributed._Util import iTasks.Extensions.Distributed._Util
import iTasks.Extensions.Distributed._Types import iTasks.Extensions.Distributed._Types
import iTasks.Extensions.Distributed._SDS import iTasks.Extensions.Distributed._SDS
import iTasks.Extensions.Distributed.Engine import iTasks.Internal.Distributed.Symbols
import iTasks.Extensions.Distributed._Evaluation import iTasks.Extensions.Distributed._Evaluation
from iTasks.Extensions.Distributed.Task import :: Domain(..) from iTasks.Extensions.Distributed.Task import :: Domain(..)
from iTasks.Extensions.Distributed._Util import repeatClient from iTasks.Extensions.Distributed._Util import repeatClient
......
...@@ -12,7 +12,6 @@ import iTasks.Extensions.Distributed._Types ...@@ -12,7 +12,6 @@ import iTasks.Extensions.Distributed._Types
import iTasks.Extensions.Distributed.Instance import iTasks.Extensions.Distributed.Instance
import iTasks.Extensions.Distributed._SDS import iTasks.Extensions.Distributed._SDS
import iTasks.Extensions.Distributed._Attributes import iTasks.Extensions.Distributed._Attributes
import iTasks.Extensions.Distributed.Engine
from iTasks.Extensions.Distributed.Task import :: Domain(..) from iTasks.Extensions.Distributed.Task import :: Domain(..)
remoteAssignTask :: !TaskAttributes (Task a) Domain -> Task a | iTask a remoteAssignTask :: !TaskAttributes (Task a) Domain -> Task a | iTask a
......
...@@ -20,7 +20,7 @@ from iTasks.Extensions.User import currentUser, :: User(..), :: UserTitle, :: Ro ...@@ -20,7 +20,7 @@ from iTasks.Extensions.User import currentUser, :: User(..), :: UserTitle, :: Ro
from iTasks.Internal.SDS import :: SDS, :: ReadWriteShared, :: RWShared, :: ReadOnlyShared, :: ROShared from iTasks.Internal.SDS import :: SDS, :: ReadWriteShared, :: RWShared, :: ReadOnlyShared, :: ROShared
from iTasks.Extensions.Distributed.Authentication import currentDomain from iTasks.Extensions.Distributed.Authentication import currentDomain
import qualified iTasks.WF.Tasks.SDS as C import qualified iTasks.WF.Tasks.SDS as C
import iTasks.Extensions.Distributed.Engine import iTasks.Internal.Distributed.Symbols
instance @: worker (Task a) | iTask a & toUserConstraint worker instance @: worker (Task a) | iTask a & toUserConstraint worker
where where
......
...@@ -8,7 +8,7 @@ import iTasks.Extensions.Distributed.Instance ...@@ -8,7 +8,7 @@ import iTasks.Extensions.Distributed.Instance
import iTasks.Extensions.Distributed._Attributes import iTasks.Extensions.Distributed._Attributes
import qualified Data.Map as DM import qualified Data.Map as DM
import Text.Encodings.Base64 import Text.Encodings.Base64
import iTasks.Extensions.Distributed.Engine import iTasks.Internal.Distributed.Symbols
from iTasks.Internal.Serialization import dynamicJSONEncode, dynamicJSONDecode from iTasks.Internal.Serialization import dynamicJSONEncode, dynamicJSONDecode
from iTasks.UI.Editor.Common import emptyEditor from iTasks.UI.Editor.Common import emptyEditor
......
...@@ -22,7 +22,7 @@ from iTasks.SDS.Sources.System import currentDateTime ...@@ -22,7 +22,7 @@ from iTasks.SDS.Sources.System import currentDateTime
from iTasks.Extensions.User import currentUser, :: User(..), :: UserTitle, :: Role, :: UserId, assign, workerAttributes, :: Password, :: Username, workAs, :: Credentials{..}, users from iTasks.Extensions.User import currentUser, :: User(..), :: UserTitle, :: Role, :: UserId, assign, workerAttributes, :: Password, :: Username, workAs, :: Credentials{..}, users
from iTasks.SDS.Definition import :: ReadWriteShared, :: RWShared, :: ReadOnlyShared from iTasks.SDS.Definition import :: ReadWriteShared, :: RWShared, :: ReadOnlyShared
from iTasks.WF.Tasks.Core import accWorld from iTasks.WF.Tasks.Core import accWorld
from iTasks.Extensions.Distributed.Engine import startDistributedEngine import iTasks.Internal.Distributed.Symbols
from iTasks.Extensions.Distributed.Instance import instanceServer, instanceClient, instanceFilter, instanceClameFilter from iTasks.Extensions.Distributed.Instance import instanceServer, instanceClient, instanceFilter, instanceClameFilter
from Data.Map import :: Map from Data.Map import :: Map
from iTasks.Extensions.Admin.WorkflowAdmin import workflow, class toWorkflow(..), :: Workflow, publish, :: PublishedTask{..}, :: TaskWrapper(..), manageWorklist, instance toWorkflow (Task a), instance toWorkflow (WorkflowContainer a), instance toWorkflow (a -> Task b), instance toWorkflow (ParamWorkflowContainer a b), :: WorkflowContainer, :: ParamWorkflowContainer from iTasks.Extensions.Admin.WorkflowAdmin import workflow, class toWorkflow(..), :: Workflow, publish, :: PublishedTask{..}, :: TaskWrapper(..), manageWorklist, instance toWorkflow (Task a), instance toWorkflow (WorkflowContainer a), instance toWorkflow (a -> Task b), instance toWorkflow (ParamWorkflowContainer a b), :: WorkflowContainer, :: ParamWorkflowContainer
......
...@@ -131,6 +131,7 @@ createClientIWorld serverURL currentInstance ...@@ -131,6 +131,7 @@ createClientIWorld serverURL currentInstance
, persistTasks = False , persistTasks = False
, autoLayout = True , autoLayout = True
, timeout = Just 100 , timeout = Just 100
, distributed = False
, webDirPath = locundef "webDirectory" , webDirPath = locundef "webDirectory"
, storeDirPath = locundef "dataDirectory" , storeDirPath = locundef "dataDirectory"
, tempDirPath = locundef "tempDirectory" , tempDirPath = locundef "tempDirectory"
......
definition module iTasks.Extensions.Distributed.Engine definition module iTasks.Internal.Distributed.Symbols
from iTasks.WF.Definition import class iTask from iTasks.WF.Definition import class iTask
from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor
...@@ -6,13 +6,11 @@ from Data.Maybe import :: Maybe ...@@ -6,13 +6,11 @@ from Data.Maybe import :: Maybe
from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
from iTasks.Internal.Generic.Visualization import :: TextFormat(..) from iTasks.Internal.Generic.Visualization import :: TextFormat(..)
from symbols_in_program import :: Symbol from symbols_in_program import :: Symbol
from iTasks.Internal.IWorld import :: IWorld
from Data.Error import :: MaybeError
from iTasks.WF.Definition import :: TaskException
/* storeSymbols :: String !*IWorld -> (MaybeError TaskException String, !*IWorld)
* Start the distributed iTasks engine.
*
* @param executable Path to executable (or library) containing the code of this server.
*/
startDistributedEngine :: String -> Task ()
accSymbols :: ({#Symbol} -> a) -> Task a | iTask a accSymbols :: ({#Symbol} -> a) -> Task a | iTask a
......
implementation module iTasks.Extensions.Distributed.Engine implementation module iTasks.Internal.Distributed.Symbols
import iTasks
from iTasks.WF.Tasks.Core import accWorld
from iTasks.Internal.SDS import read, write
import symbols_in_program
from iTasks.Internal.IWorld import :: IWorld{world}
from Data.Error import :: MaybeError(..)
from iTasks.WF.Definition import :: TaskException, :: Task(..), :: TaskResult, :: TaskEvalOpts, :: Event(..), :: Set
from iTasks.Internal.Task import mkInstantTask
from iTasks.Internal.TaskState import :: TaskTree
from iTasks.WF.Definition import class iTask
from iTasks.Internal.SDS import :: ReadWriteShared, :: RWShared, :: Shared
from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor, :: TaskId
from Data.Maybe import :: Maybe
from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
from iTasks.Internal.Generic.Visualization import :: TextFormat(..)
import StdFile import StdFile
//from iTasks.WF.Tasks.Core import accWorld
//from iTasks.Internal.SDS import read, write
import symbols_in_program
//from iTasks.Internal.IWorld import :: IWorld{world}
//from Data.Error import :: MaybeError(..)
//from iTasks.WF.Definition import :: TaskException, :: Task(..), :: TaskResult, :: TaskEvalOpts, :: Event(..), :: Set
//from iTasks.Internal.Task import mkInstantTask
//from iTasks.Internal.TaskState import :: TaskTree
//from iTasks.WF.Definition import class iTask
//from iTasks.Internal.SDS import :: ReadWriteShared, :: RWShared, :: Shared
//from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor, :: TaskId
//from Data.Maybe import :: Maybe
//from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
//from iTasks.Internal.Generic.Visualization import :: TextFormat(..)
//import StdFile
import dynamic_string import dynamic_string
import Text.Encodings.Base64 import Text.Encodings.Base64
from iTasks.WF.Combinators.Common import @!, >>-
from iTasks.WF.Tasks.SDS import set import iTasks.Internal.SDS
from iTasks.SDS.Sources.Store import :: SDS, sharedStore import iTasks.Internal.Task
import StdTuple import iTasks.Internal.IWorld
//from iTasks.WF.Combinators.Common import @!, >>-
//from iTasks.WF.Tasks.SDS import set
//from iTasks.SDS.Sources.Store import :: SDS, sharedStore
//import StdTuple
symbolsShare :: Shared String symbolsShare :: Shared String
symbolsShare = sharedStore "symbols" "" symbolsShare = sharedStore "symbols" ""
startDistributedEngine :: String -> Task () storeSymbols :: String !*IWorld -> (MaybeError TaskException String, !*IWorld)
startDistributedEngine executable = storeSymbols executable storeSymbols file iworld
# (symbols, iworld) = accFiles (read_symbols file) iworld
storeSymbols :: String -> Task () # val = base64Encode (copy_to_string symbols)
storeSymbols file = mkInstantTask eval # (res, iworld) = write val symbolsShare iworld
where | isError res = (liftError res, iworld)
eval taskId iworld=:{IWorld|world} = (Ok val, iworld)
# (symbols, world) = accFiles (read_symbols file) world
# iworld = {IWorld| iworld & world = world}
# val = base64Encode (copy_to_string symbols)
# (res,iworld) = write val symbolsShare iworld
= case res of
Ok _ = (Ok (), iworld)
Error e = (Error e, iworld)
accSymbols :: ({#Symbol} -> a) -> Task a | iTask a accSymbols :: ({#Symbol} -> a) -> Task a | iTask a
accSymbols fun = mkInstantTask eval accSymbols fun = mkInstantTask eval
...@@ -56,4 +56,3 @@ where ...@@ -56,4 +56,3 @@ where
# (val, iworld) = read symbolsShare iworld # (val, iworld) = read symbolsShare iworld
= case val of = case val of
Ok val = let (Task eval`) = taskfun (fst (copy_from_string (base64Decode val))) in eval` event evalOpts state iworld Ok val = let (Task eval`) = taskfun (fst (copy_from_string (base64Decode val))) in eval` event evalOpts state iworld
...@@ -6,7 +6,7 @@ from Data.Maybe import :: Maybe ...@@ -6,7 +6,7 @@ from Data.Maybe import :: Maybe
from Data.Error import :: MaybeError(..), :: MaybeErrorString(..) from Data.Error import :: MaybeError(..), :: MaybeErrorString(..)
from Data.Set import :: Set from Data.Set import :: Set
from Data.Queue import :: Queue from Data.Queue import :: Queue
from StdFile import class FileSystem from StdFile import class FileSystem, class FileEnv
from System.Time import :: Timestamp, :: Timespec from System.Time import :: Timestamp, :: Timespec
from Text.GenJSON import :: JSONNode from Text.GenJSON import :: JSONNode
from iTasks.Engine import :: EngineOptions from iTasks.Engine import :: EngineOptions
...@@ -161,3 +161,4 @@ iworldLocalDateTime` :: !*IWorld -> (!DateTime, !*IWorld) ...@@ -161,3 +161,4 @@ iworldLocalDateTime` :: !*IWorld -> (!DateTime, !*IWorld)
iworldResource :: (*Resource -> (Bool, *Resource)) *IWorld -> (*[*Resource], *IWorld) iworldResource :: (*Resource -> (Bool, *Resource)) *IWorld -> (*[*Resource], *IWorld)
instance FileSystem IWorld instance FileSystem IWorld
instance FileEnv IWorld
...@@ -15,8 +15,8 @@ import Data.Integer ...@@ -15,8 +15,8 @@ import Data.Integer
import iTasks.SDS.Combinators.Common import iTasks.SDS.Combinators.Common
from StdFile import class FileSystem(..) from StdFile import class FileSystem(..), class FileEnv(..), :: Files
from StdFile import instance FileSystem World from StdFile import instance FileSystem World, instance FileEnv World
from StdFunc import const, o, seqList, :: St from StdFunc import const, o, seqList, :: St
from StdMisc import abort from StdMisc import abort
from StdOrdList import sortBy from StdOrdList import sortBy
...@@ -185,3 +185,12 @@ where ...@@ -185,3 +185,12 @@ where
sfopen filename mode iworld=:{IWorld|world} sfopen filename mode iworld=:{IWorld|world}
# (ok,file,world) = sfopen filename mode world # (ok,file,world) = sfopen filename mode world
= (ok,file,{IWorld|iworld & world = world}) = (ok,file,{IWorld|iworld & world = world})
instance FileEnv IWorld
where
accFiles accfun iworld=:{IWorld|world}
# (x, world) = accFiles accfun world
= (x, {IWorld | iworld & world=world})
appFiles appfun iworld=:{IWorld|world}
# world = appFiles appfun world
= {IWorld | iworld & world=world}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment