Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
clean-and-itasks
iTasks-SDK
Commits
7bc0337b
Commit
7bc0337b
authored
Jul 28, 2018
by
Bas Lijnse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed `runTasks` alternative main function.
It now possible to do the same with `doTasks`
parent
d6aba26b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
98 deletions
+48
-98
Libraries/iTasks/Engine.dcl
Libraries/iTasks/Engine.dcl
+40
-53
Libraries/iTasks/Engine.icl
Libraries/iTasks/Engine.icl
+8
-45
No files found.
Libraries/iTasks/Engine.dcl
View file @
7bc0337b
...
...
@@ -2,16 +2,54 @@ definition module iTasks.Engine
/**
* This module provides the iTasks engine.
* This is the primary function that creates the complete
* environment in which
worfklow specification
s can be executed.
* environment in which
task
s can be executed.
*/
from
Data
.
Maybe
import
::
Maybe
from
System
.
FilePath
import
::
FilePath
from
Internet
.
HTTP
import
::
HTTPRequest
from
System
.
Time
import
::
Timespec
from
Internet
.
HTTP
import
::
HTTPRequest
import
iTasks
.
WF
.
Definition
/*
* There are two ways tasks can be started:
* Interactively when a user requests it through the web,
* or directly when the application (server) is started,
*/
::
StartableTask
=
WebTask
!
WebTask
|
StartupTask
!
StartupTask
::
WebTask
=
{
url
::
!
String
,
task
::
!
WebTaskWrapper
}
::
StartupTask
=
{
attributes
::
!
TaskAttributes
,
task
::
!
TaskWrapper
}
::
WebTaskWrapper
=
E
.
a
:
WebTaskWrapper
(
HTTPRequest
->
Task
a
)
&
iTask
a
::
TaskWrapper
=
E
.
a
:
TaskWrapper
(
Task
a
)
&
iTask
a
//Utility functions for creating collections of startable tasks
atRequest
::
String
(
HTTPRequest
->
Task
a
)
->
StartableTask
|
iTask
a
atStartup
::
TaskAttributes
(
Task
a
)
->
StartableTask
|
iTask
a
publish
:==
atRequest
//Backwards compatibility
class
Startable
a
where
toStartable
::
!
a
->
[
StartableTask
]
instance
Startable
(
Task
a
)
|
iTask
a
//Default as web task
instance
Startable
(
HTTPRequest
->
Task
a
)
|
iTask
a
//As web task
instance
Startable
StartableTask
instance
Startable
[
StartableTask
]
::
EngineOptions
=
{
appName
::
String
,
appPath
::
FilePath
// Location of the application's executable
...
...
@@ -69,57 +107,6 @@ startEngineWithOptions :== doTasksWithOptions
*/
defaultEngineCLIOptions
::
[
String
]
EngineOptions
->
(!
Maybe
EngineOptions
,![
String
])
/**
* Start a stripped task engine (without an HTTP server) with a list of tasks to be created
*/
runTasks
::
a
!*
World
->
*
World
|
Runnable
a
runTasksWithOptions
::
([
String
]
EngineOptions
->
(!
Maybe
EngineOptions
,![
String
]))
a
!*
World
->
*
World
|
Runnable
a
/*
* There are two ways tasks can be started:
* Interactively when a user requests it through the web,
* or directly when the application (server) is started,
*/
::
StartableTask
=
WebTask
!
WebTask
|
StartupTask
!
StartupTask
::
WebTask
=
{
url
::
!
String
,
task
::
!
WebTaskWrapper
}
::
StartupTask
=
{
attributes
::
!
TaskAttributes
,
task
::
!
TaskWrapper
}
::
WebTaskWrapper
=
E
.
a
:
WebTaskWrapper
(
HTTPRequest
->
Task
a
)
&
iTask
a
::
TaskWrapper
=
E
.
a
:
TaskWrapper
(
Task
a
)
&
iTask
a
//Utility functions for creating collections of startable tasks
atRequest
::
String
(
HTTPRequest
->
Task
a
)
->
StartableTask
|
iTask
a
atStartup
::
TaskAttributes
(
Task
a
)
->
StartableTask
|
iTask
a
publish
:==
atRequest
//Backwards compatibility
class
Startable
a
where
toStartable
::
!
a
->
[
StartableTask
]
instance
Startable
(
Task
a
)
|
iTask
a
//Default as web task
instance
Startable
(
HTTPRequest
->
Task
a
)
|
iTask
a
//As web task
instance
Startable
StartableTask
instance
Startable
[
StartableTask
]
// === Wrapping non-interactive tasks for running on the command line ===
class
Runnable
a
where
toRunnable
::
!
a
->
[
StartableTask
]
instance
Runnable
(
Task
a
)
|
iTask
a
/**
* Determines the default options for an application
*/
...
...
Libraries/iTasks/Engine.icl
View file @
7bc0337b
...
...
@@ -142,40 +142,8 @@ where
]
[
BackgroundTask
stopOnStable
]
]
runTasksWithOptions
::
([
String
]
EngineOptions
->
(!
Maybe
EngineOptions
,![
String
]))
a
!*
World
->
*
World
|
Runnable
a
runTasksWithOptions
initFun
runnable
world
#
(
cli
,
world
)
=
getCommandLine
world
#
(
options
,
world
)
=
defaultEngineOptions
world
#
(
mbOptions
,
msg
)
=
initFun
cli
options
#
world
=
show
msg
world
|
mbOptions
=:
Nothing
=
world
#
(
Just
options
)
=
mbOptions
#
iworld
=
createIWorld
options
world
#
(
res
,
iworld
)
=
initJSCompilerState
iworld
|
res
=:(
Error
_)
=
show
[
"Fatal error: "
+++
fromError
res
]
(
destroyIWorld
iworld
)
#
iworld
=
serve
startupTasks
[]
systemTasks
(
timeout
options
.
timeout
)
iworld
=
destroyIWorld
iworld
where
startupTasks
=
[
t
\\
StartupTask
t
<-
toRunnable
runnable
]
systemTasks
=
[
BackgroundTask
updateClock
,
BackgroundTask
(
processEvents
MAX_EVENTS
)
,
BackgroundTask
stopOnStable
]
runTasks
::
a
!*
World
->
*
World
|
Runnable
a
runTasks
tasks
world
=
runTasksWithOptions
(\
c
o
->
(
Just
o
,[]))
tasks
world
show
::
![
String
]
!*
World
->
*
World
show
lines
world
#
(
console
,
world
)
=
stdio
world
#
console
=
seqSt
(\
s
c
->
fwrites
(
s
+++
"
\n
"
)
c
)
lines
console
#
(_,
world
)
=
fclose
console
world
=
world
// The iTasks engine consist of a set of HTTP Web
S
ervice
// The iTasks engine consist of a set of HTTP Web
s
ervice
s
engineWebService
::
[
WebTask
]
->
[
WebService
(
Map
InstanceNo
TaskOutput
)
(
Map
InstanceNo
TaskOutput
)]
engineWebService
webtasks
=
[
taskUIService
webtasks
...
...
@@ -184,24 +152,19 @@ engineWebService webtasks =
,
staticResourceService
[
url
\\
{
WebTask
|
url
}
<-
webtasks
]
]
show
::
![
String
]
!*
World
->
*
World
show
lines
world
#
(
console
,
world
)
=
stdio
world
#
console
=
seqSt
(\
s
c
->
fwrites
(
s
+++
"
\n
"
)
c
)
lines
console
#
(_,
world
)
=
fclose
console
world
=
world
atRequest
::
String
(
HTTPRequest
->
Task
a
)
->
StartableTask
|
iTask
a
atRequest
url
task
=
WebTask
{
WebTask
|
url
=
url
,
task
=
WebTaskWrapper
task
}
atStartup
::
TaskAttributes
(
Task
a
)
->
StartableTask
|
iTask
a
atStartup
attributes
task
=
StartupTask
{
StartupTask
|
attributes
=
attributes
,
task
=
TaskWrapper
task
}
class
Runnable
a
where
toRunnable
::
!
a
->
[
StartableTask
]
instance
Runnable
(
Task
a
)
|
iTask
a
where
toRunnable
task
=
[
StartupTask
{
StartupTask
|
attributes
='
DM
'.
newMap
,
task
=
TaskWrapper
task
}]
instance
Runnable
[
StartableTask
]
where
toRunnable
list
=
list
class
Startable
a
where
toStartable
::
!
a
->
[
StartableTask
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment