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
158
Issues
158
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
1adb6049
Commit
1adb6049
authored
Apr 06, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP connection pool
parent
d5e91d51
Pipeline
#805
failed with stage
Changes
16
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
39 additions
and
24 deletions
+39
-24
API.hs
src/Gargantext/API.hs
+2
-2
Auth.hs
src/Gargantext/API/Auth.hs
+3
-3
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+9
-7
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+1
-0
Settings.hs
src/Gargantext/API/Settings.hs
+13
-12
Types.hs
src/Gargantext/Core/Flow/Types.hs
+1
-0
Pairing.hs
src/Gargantext/Database/Flow/Pairing.hs
+1
-0
Utils.hs
src/Gargantext/Database/Flow/Utils.hs
+1
-0
Init.hs
src/Gargantext/Database/Init.hs
+1
-0
NgramsByNode.hs
src/Gargantext/Database/Metrics/NgramsByNode.hs
+1
-0
Insert.hs
src/Gargantext/Database/Node/Document/Insert.hs
+1
-0
NodeNgrams.hs
src/Gargantext/Database/Schema/NodeNgrams.hs
+1
-0
NodeNodeNgrams.hs
src/Gargantext/Database/Schema/NodeNodeNgrams.hs
+1
-0
NodeNodeNgrams2.hs
src/Gargantext/Database/Schema/NodeNodeNgrams2.hs
+1
-0
NodesNgramsRepo.hs
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
+1
-0
TextSearch.hs
src/Gargantext/Database/TextSearch.hs
+1
-0
No files found.
src/Gargantext/API.hs
View file @
1adb6049
...
...
@@ -86,7 +86,7 @@ import Gargantext.API.Types
import
Gargantext.Database.Node.Contact
(
HyperdataContact
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
(
NodeId
,
CorpusId
,
AnnuaireId
)
import
Gargantext.Database.Utils
(
HasConnection
)
import
Gargantext.Database.Utils
(
HasConnection
Pool
)
import
Gargantext.Prelude
import
Gargantext.Viz.Graph.API
import
Network.HTTP.Types
hiding
(
Query
)
...
...
@@ -334,7 +334,7 @@ type API = SwaggerAPI
type
GargServerM
env
err
=
ReaderT
env
(
ExceptT
err
IO
)
type
EnvC
env
=
(
HasConnection
env
(
HasConnection
Pool
env
,
HasRepo
env
,
HasSettings
env
,
HasJobEnv
env
ScraperStatus
ScraperStatus
...
...
src/Gargantext/API/Auth.hs
View file @
1adb6049
...
...
@@ -50,7 +50,7 @@ import Gargantext.API.Types (HasJoseError(..), joseError, HasServerError, GargSe
import
Gargantext.Database.Root
(
getRoot
)
import
Gargantext.Database.Tree
(
isDescendantOf
,
isIn
)
import
Gargantext.Database.Types.Node
(
NodePoly
(
_node_id
),
NodeId
(
..
),
UserId
,
ListId
,
DocId
)
import
Gargantext.Database.Utils
(
Cmd
'
,
CmdM
,
HasConnection
)
import
Gargantext.Database.Utils
(
Cmd
'
,
CmdM
,
HasConnection
Pool
)
import
Gargantext.Prelude
hiding
(
reverse
)
import
Test.QuickCheck
(
elements
,
oneof
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
...
...
@@ -96,7 +96,7 @@ makeTokenForUser uid = do
either
joseError
(
pure
.
toStrict
.
decodeUtf8
)
e
-- TODO not sure about the encoding...
checkAuthRequest
::
(
HasSettings
env
,
HasConnection
env
,
HasJoseError
err
)
checkAuthRequest
::
(
HasSettings
env
,
HasConnection
Pool
env
,
HasJoseError
err
)
=>
Username
->
Password
->
Cmd'
env
err
CheckAuth
checkAuthRequest
u
p
|
not
(
u
`
elem
`
arbitraryUsername
)
=
pure
InvalidUser
...
...
@@ -109,7 +109,7 @@ checkAuthRequest u p
token
<-
makeTokenForUser
uid
pure
$
Valid
token
uid
auth
::
(
HasSettings
env
,
HasConnection
env
,
HasJoseError
err
)
auth
::
(
HasSettings
env
,
HasConnection
Pool
env
,
HasJoseError
err
)
=>
AuthRequest
->
Cmd'
env
err
AuthResponse
auth
(
AuthRequest
u
p
)
=
do
checkAuthRequest'
<-
checkAuthRequest
u
p
...
...
src/Gargantext/API/Ngrams.hs
View file @
1adb6049
...
...
@@ -122,6 +122,7 @@ import Control.Lens (makeLenses, makePrisms, Getter, Iso', iso, from, (.~), (?=)
import
Control.Monad.Error.Class
(
MonadError
)
import
Control.Monad.Reader
import
Control.Monad.State
import
Control.Monad.Trans.Control
(
MonadBaseControl
)
import
Data.Aeson
hiding
((
.=
))
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Either
(
Either
(
Left
))
...
...
@@ -140,7 +141,7 @@ import Gargantext.Database.Config (userMaster)
import
Gargantext.Database.Metrics.NgramsByNode
(
getOccByNgramsOnlyFast'
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Types.Node
(
NodeType
(
..
))
import
Gargantext.Database.Utils
(
fromField'
,
HasConnection
)
import
Gargantext.Database.Utils
(
fromField'
,
HasConnection
Pool
)
import
Gargantext.Database.Node.Select
import
Gargantext.Database.Ngrams
--import Gargantext.Database.Lists (listsWith)
...
...
@@ -796,7 +797,8 @@ instance HasRepoSaver RepoEnv where
type
RepoCmdM
env
err
m
=
(
MonadReader
env
m
,
MonadError
err
m
,
MonadIO
m
,
MonadIO
m
-- TODO liftIO -> liftBase
,
MonadBaseControl
IO
m
,
HasRepo
env
)
------------------------------------------------------------------------
...
...
@@ -1023,7 +1025,7 @@ getTime' = liftIO $ getTime ProcessCPUTime
getTableNgrams
::
forall
env
err
m
.
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
Pool
env
)
=>
NodeType
->
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
...
...
@@ -1184,7 +1186,7 @@ type TableNgramsApi = TableNgramsApiGet
:<|>
TableNgramsApiPut
:<|>
TableNgramsApiPost
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
Pool
env
)
=>
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
...
...
@@ -1198,7 +1200,7 @@ getTableNgramsCorpus nId tabType listId limit_ offset listType minSize maxSize o
searchQuery
=
maybe
(
const
True
)
isInfixOf
mt
-- | Text search is deactivated for now for ngrams by doc only
getTableNgramsDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
getTableNgramsDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
Pool
env
)
=>
DocId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
...
...
@@ -1218,7 +1220,7 @@ getTableNgramsDoc dId tabType listId limit_ offset listType minSize maxSize orde
apiNgramsTableCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasInvalidError
err
,
HasConnection
env
,
HasConnection
Pool
env
)
=>
NodeId
->
ServerT
TableNgramsApi
m
apiNgramsTableCorpus
cId
=
getTableNgramsCorpus
cId
...
...
@@ -1229,7 +1231,7 @@ apiNgramsTableCorpus cId = getTableNgramsCorpus cId
apiNgramsTableDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasInvalidError
err
,
HasConnection
env
,
HasConnection
Pool
env
)
=>
DocId
->
ServerT
TableNgramsApi
m
apiNgramsTableDoc
dId
=
getTableNgramsDoc
dId
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
1adb6049
...
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
...
...
src/Gargantext/API/Settings.hs
View file @
1adb6049
...
...
@@ -35,13 +35,14 @@ import System.Environment (lookupEnv)
import
System.IO
(
FilePath
,
hClose
)
import
System.IO.Temp
(
withTempFile
)
import
System.FileLock
(
tryLockFile
,
unlockFile
,
SharedExclusive
(
Exclusive
))
import
Database.PostgreSQL.Simple
(
Connection
,
connect
,
close
,
PGS
ConnectInfo
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
,
close
,
ConnectInfo
)
import
Network.HTTP.Client
(
Manager
)
import
Network.HTTP.Client.TLS
(
newTlsManager
)
import
Data.Aeson
import
Data.Maybe
(
fromMaybe
)
import
Data.Either
(
either
)
import
Data.Pool
(
Pool
,
createPool
)
import
Data.Text
--import Data.Text.Encoding (encodeUtf8)
import
Data.ByteString
(
ByteString
)
...
...
@@ -61,7 +62,7 @@ import Control.Monad.Logger
import
Control.Monad.Reader
import
Control.Lens
import
Gargantext.Prelude
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
(
..
),
Cmd
'
,
runCmd
)
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
Pool
(
..
),
Cmd
'
,
runCmd
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
HasRepoSaver
(
..
),
HasRepo
(
..
),
RepoEnv
(
..
),
r_version
,
saveRepo
,
initRepo
,
renv_var
,
renv_lock
)
import
Gargantext.API.Orchestrator.Types
...
...
@@ -141,7 +142,7 @@ data FireWall = FireWall { unFireWall :: Bool }
data
Env
=
Env
{
_env_settings
::
!
Settings
,
_env_logger
::
!
LoggerSet
,
_env_
conn
::
!
Connection
,
_env_
pool
::
!
(
Pool
Connection
)
,
_env_repo
::
!
RepoEnv
,
_env_manager
::
!
Manager
,
_env_self_url
::
!
BaseUrl
...
...
@@ -151,8 +152,8 @@ data Env = Env
makeLenses
''
E
nv
instance
HasConnection
Env
where
conn
ection
=
env_conn
instance
HasConnection
Pool
Env
where
conn
Pool
=
env_pool
instance
HasRepoVar
Env
where
repoVar
=
repoEnv
.
repoVar
...
...
@@ -254,7 +255,7 @@ newEnv port file = do
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
param
<-
databaseParameters
file
conn
<-
connect
param
pool
<-
newPool
param
repo
<-
readRepoEnv
scrapers_env
<-
newJobEnv
defaultSettings
manager
logger
<-
newStderrLoggerSet
defaultBufSize
...
...
@@ -262,26 +263,26 @@ newEnv port file = do
pure
$
Env
{
_env_settings
=
settings
,
_env_logger
=
logger
,
_env_
conn
=
conn
,
_env_
pool
=
pool
,
_env_repo
=
repo
,
_env_manager
=
manager
,
_env_scrapers
=
scrapers_env
,
_env_self_url
=
self_url
}
newPool
::
PGSConnectInfo
->
IO
(
Pool
a
)
newPool
::
ConnectInfo
->
IO
(
Pool
Connection
)
newPool
param
=
createPool
(
connect
param
)
close
1
(
60
*
60
)
8
data
DevEnv
=
DevEnv
{
_dev_env_
conn
::
!
Connection
{
_dev_env_
pool
::
!
(
Pool
Connection
)
,
_dev_env_repo
::
!
RepoEnv
,
_dev_env_settings
::
!
Settings
}
makeLenses
''
D
evEnv
instance
HasConnection
DevEnv
where
conn
ection
=
dev_env_conn
instance
HasConnection
Pool
DevEnv
where
conn
Pool
=
dev_env_pool
instance
HasRepoVar
DevEnv
where
repoVar
=
repoEnv
.
repoVar
...
...
@@ -329,7 +330,7 @@ runCmdReplServantErr = runCmdRepl
-- In particular this writes the repo file after running
-- the command.
-- This function is constrained to the DevEnv rather than
-- using HasConnection and HasRepoVar.
-- using HasConnection
Pool
and HasRepoVar.
runCmdDev
::
Show
err
=>
DevEnv
->
Cmd'
DevEnv
err
a
->
IO
a
runCmdDev
env
f
=
(
either
(
fail
.
show
)
pure
=<<
runCmd
env
f
)
...
...
src/Gargantext/Core/Flow/Types.hs
View file @
1adb6049
...
...
@@ -10,6 +10,7 @@ Portability : POSIX
-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstrainedClassMethods #-}
...
...
src/Gargantext/Database/Flow/Pairing.hs
View file @
1adb6049
...
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Flow/Utils.hs
View file @
1adb6049
...
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
...
...
src/Gargantext/Database/Init.hs
View file @
1adb6049
...
...
@@ -11,6 +11,7 @@ Ngrams by node enable contextual metrics.
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Metrics/NgramsByNode.hs
View file @
1adb6049
...
...
@@ -11,6 +11,7 @@ Ngrams by node enable contextual metrics.
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Node/Document/Insert.hs
View file @
1adb6049
...
...
@@ -49,6 +49,7 @@ the concatenation of the parameters defined by @shaParameters@.
-}
------------------------------------------------------------------------
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
...
...
src/Gargantext/Database/Schema/NodeNgrams.hs
View file @
1adb6049
...
...
@@ -15,6 +15,7 @@ NodeNgrams register Context of Ngrams (named Cgrams then)
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE QuasiQuotes #-}
...
...
src/Gargantext/Database/Schema/NodeNodeNgrams.hs
View file @
1adb6049
...
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
...
...
src/Gargantext/Database/Schema/NodeNodeNgrams2.hs
View file @
1adb6049
...
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
...
...
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
View file @
1adb6049
...
...
@@ -13,6 +13,7 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
...
...
src/Gargantext/Database/TextSearch.hs
View file @
1adb6049
...
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
...
...
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