Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
af381f0a
Commit
af381f0a
authored
Mar 13, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generalise type of serveJobsAPI
parent
71a30935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
Jobs.hs
src/Gargantext/Utils/Jobs.hs
+17
-11
No files found.
src/Gargantext/Utils/Jobs.hs
View file @
af381f0a
{-# LANGUAGE TypeFamilies #-}
module
Gargantext.Utils.Jobs
(
-- * Serving the JOBS API
serveJobsAPI
...
...
@@ -7,12 +8,13 @@ module Gargantext.Utils.Jobs (
import
Control.Monad.Except
import
Control.Monad.Reader
import
Data.Aeson
(
ToJSON
)
import
Data.Monoid
(
Dual
)
import
Prelude
import
System.Directory
(
doesFileExist
)
import
Text.Read
(
readMaybe
)
import
Gargantext.API.Admin.EnvTypes
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
)
import
Gargantext.API.Prelude
import
qualified
Gargantext.Utils.Jobs.Internal
as
Internal
import
Gargantext.Utils.Jobs.Map
...
...
@@ -25,18 +27,22 @@ jobErrorToGargError
jobErrorToGargError
=
GargJobError
serveJobsAPI
::
Foldable
callbacks
=>
GargJob
->
(
input
->
Logger
JobLog
->
GargM
Env
GargError
JobLog
)
->
JobsServerAPI
ctI
ctO
callbacks
input
serveJobsAPI
t
f
=
Internal
.
serveJobsAPI
ask
t
jobErrorToGargError
$
\
env
i
l
->
do
putStrLn
(
"Running job of type: "
++
show
t
)
::
(
Foldable
callbacks
,
Ord
jobType
,
Show
jobType
,
ToJSON
event
,
ToJSON
result
,
MonadJob
m
jobType
(
Dual
[
event
])
result
,
m
~
(
GargM
env
GargError
)
)
=>
jobType
->
(
input
->
Logger
event
->
m
result
)
->
SJ
.
AsyncJobsServerT'
ctI
ctO
callbacks
event
input
result
m
serveJobsAPI
jobType
f
=
Internal
.
serveJobsAPI
ask
jobType
jobErrorToGargError
$
\
env
i
l
->
do
putStrLn
(
"Running job of type: "
++
show
jobType
)
runExceptT
$
runReaderT
(
f
i
l
)
env
type
JobsServerAPI
ctI
ctO
callbacks
input
=
SJ
.
AsyncJobsServerT'
ctI
ctO
callbacks
JobLog
input
JobLog
(
GargM
Env
GargError
)
parseGargJob
::
String
->
Maybe
GargJob
parseGargJob
s
=
case
s
of
"tablengrams"
->
Just
TableNgramsJob
...
...
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