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
144
Issues
144
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
f0e0f347
Verified
Commit
f0e0f347
authored
Sep 03, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] NewTask notification
parent
19f4848f
Pipeline
#6573
failed with stages
in 13 minutes and 34 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
EnvTypes.hs
src/Gargantext/API/Admin/EnvTypes.hs
+22
-0
Types.hs
src/Gargantext/Core/AsyncUpdates/Dispatcher/Types.hs
+20
-4
No files found.
src/Gargantext/API/Admin/EnvTypes.hs
View file @
f0e0f347
...
...
@@ -114,6 +114,28 @@ data GargJob
|
AddAnnuaireFormJob
|
RecomputeGraphJob
deriving
(
Show
,
Eq
,
Ord
,
Enum
,
Bounded
)
instance
ToJSON
GargJob
where
toJSON
=
toJSON
.
show
instance
FromJSON
GargJob
where
parseJSON
=
withText
$
\
t
->
case
t
of
"TableNgramsJob"
->
pure
TableNgramsJob
"ForgotPasswordJob"
->
pure
ForgotPasswordJob
"UpdateNgramsListJobJSON"
->
pure
UpdateNgramsListJobJSON
"UpdateNgramsListJobTSV"
->
pure
UpdateNgramsListJobTSV
"AddContactJob"
->
pure
AddContactJob
"AddFileJob"
->
pure
AddFileJob
"DocumentFromWriteNodeJob"
->
pure
DocumentFromWriteNodeJob
"UpdateNodeJob"
->
pure
UpdateNodeJob
"UploadFrameCalcJob"
->
pure
UploadFrameCalcJob
"UploadDocumentJob"
->
pure
UploadDocumentJob
"NewNodeJob"
->
pure
NewNodeJob
"AddCorpusQueryJob"
->
pure
AddCorpusQueryJob
"AddCorpusFormJob"
->
pure
AddCorpusFormJob
"AddCorpusFileJob"
->
pure
AddCorpusFileJob
"AddAnnuaireFormJob"
->
pure
AddAnnuaireFormJob
"RecomputeGraphJob"
->
pure
RecomputeGraphJob
s
->
prependFailure
"parsing GargJob failed, "
(
typeMismatch
"gargJob"
s
)
-- Do /not/ treat the data types of this type as strict, because it's convenient
-- to be able to partially initialise things like an 'Env' during tests, without
...
...
src/Gargantext/Core/AsyncUpdates/Dispatcher/Types.hs
View file @
f0e0f347
...
...
@@ -29,6 +29,7 @@ import Data.ByteString.Lazy qualified as BSL
import
Data.List
(
nubBy
)
import
DeferredFolds.UnfoldlM
qualified
as
UnfoldlM
import
Data.UUID.V4
as
UUID
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
))
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
(
_auth_user_id
))
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
)
import
Gargantext.API.Admin.Types
(
jwtSettings
,
Settings
,
jwtSettings
)
...
...
@@ -55,23 +56,32 @@ import StmContainers.Set as SSet
-- | A topic is sent, when a client wants to subscribe to specific
-- | types of notifications
data
Topic
=
-- | New task appeared on given node
NewTask
NodeId
(
JobID
'S
a
fe
)
GargJob
-- | Update given Servant Job (we currently send a request every
-- | second to get job status).
UpdateJobProgress
(
JobID
'S
a
fe
)
|
UpdateJobProgress
(
JobID
'S
a
fe
)
-- | Given parent node id, trigger update of the node and its
-- children (e.g. list is automatically created in a corpus)
|
UpdateTree
NodeId
deriving
(
Eq
,
Ord
)
instance
Prelude
.
Show
Topic
where
show
(
NewTask
nodeId
jId
gargJob
)
=
"NewTask "
<>
(
show
nodeId
)
<>
", "
<>
(
CBUTF8
.
decode
$
BSL
.
unpack
$
Aeson
.
encode
jId
)
<>
", "
<>
show
gargJob
show
(
UpdateJobProgress
jId
)
=
"UpdateJobProgress "
<>
(
CBUTF8
.
decode
$
BSL
.
unpack
$
Aeson
.
encode
jId
)
show
(
UpdateTree
nodeId
)
=
"UpdateTree "
<>
show
nodeId
instance
Hashable
Topic
where
hashWithSalt
salt
(
NewTask
nodeId
jId
gargJob
)
=
hashWithSalt
salt
(
"new-task"
::
Text
,
nodeId
,
Aeson
.
encode
jId
,
show
gargJob
)
hashWithSalt
salt
(
UpdateJobProgress
jId
)
=
hashWithSalt
salt
(
"update-job-progress"
::
Text
,
Aeson
.
encode
jId
)
hashWithSalt
salt
(
UpdateTree
nodeId
)
=
hashWithSalt
salt
(
"update-tree"
::
Text
,
nodeId
)
instance
FromJSON
Topic
where
parseJSON
=
Aeson
.
withObject
"Topic"
$
\
o
->
do
type_
<-
o
.:
"type"
case
type_
of
"new_task"
->
do
nodeId
<=
o
.:
"node_id"
jId
<-
o
.:
"j_id"
gargJob
<-
o
.:
"garg_job"
pure
$
NewTask
nodeId
jId
gargJob
"update_job_progress"
->
do
jId
<-
o
.:
"j_id"
pure
$
UpdateJobProgress
jId
...
...
@@ -80,13 +90,19 @@ instance FromJSON Topic where
pure
$
UpdateTree
node_id
s
->
prependFailure
"parsing type failed, "
(
typeMismatch
"type"
s
)
instance
ToJSON
Topic
where
toJSON
(
NewTask
nodeId
jId
gargJob
)
=
Aeson
.
object
[
"type"
.=
toJSON
(
"new_task"
::
Text
)
,
"node_id"
.=
toJSON
nodeId
,
"j_id"
.=
toJSON
jId
,
"garg_job"
.=
toJSON
gargJob
]
toJSON
(
UpdateJobProgress
jId
)
=
Aeson
.
object
[
"type"
.=
toJSON
(
"update_job_progress"
::
Text
)
,
"j_id"
.=
toJSON
jId
]
toJSON
(
UpdateTree
node
_i
d
)
=
Aeson
.
object
[
toJSON
(
UpdateTree
node
I
d
)
=
Aeson
.
object
[
"type"
.=
toJSON
(
"update_tree"
::
Text
)
,
"node_id"
.=
toJSON
node
_i
d
,
"node_id"
.=
toJSON
node
I
d
]
-- | A message to be sent inside a Notification
...
...
@@ -167,7 +183,7 @@ by default can handle 65k concurrent connections. With multiple users
having multiple components open, we could exhaust that limit quickly.
Hence, we architect this to have 1 websocket connection per web
browser.
-
browser.
-}
data
WSRequest
=
WSSubscribe
Topic
...
...
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