Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
crawlers
hal
Commits
8bf9fc69
Verified
Commit
8bf9fc69
authored
Dec 09, 2024
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[refactor] upgrade servant-client to 0.20
parent
229fdf40
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
crawlerHAL.cabal
crawlerHAL.cabal
+6
-3
HAL.hs
src/HAL.hs
+6
-15
ServantClientLogging.hs
src/HAL/ServantClientLogging.hs
+30
-0
No files found.
crawlerHAL.cabal
View file @
8bf9fc69
...
@@ -32,6 +32,7 @@ library
...
@@ -32,6 +32,7 @@ library
HAL.Doc.Document
HAL.Doc.Document
HAL.Doc.EntityTree
HAL.Doc.EntityTree
HAL.Doc.Struct
HAL.Doc.Struct
HAL.ServantClientLogging
HAL.Types
HAL.Types
HAL.Utils
HAL.Utils
Tree
Tree
...
@@ -51,6 +52,7 @@ library
...
@@ -51,6 +52,7 @@ library
build-depends:
build-depends:
aeson >= 1.5.6 && < 2.3
aeson >= 1.5.6 && < 2.3
, base >=4.7 && <5
, base >=4.7 && <5
, binary >= 0.8.8 && < 0.9
, bytestring >= 0.11.0 && < 0.13
, bytestring >= 0.11.0 && < 0.13
, conduit >= 1.3.5 && < 1.4
, conduit >= 1.3.5 && < 1.4
, containers >= 0.6.7 && < 0.7
, containers >= 0.6.7 && < 0.7
...
@@ -63,8 +65,9 @@ library
...
@@ -63,8 +65,9 @@ library
, optparse-applicative >= 0.17 && < 0.19
, optparse-applicative >= 0.17 && < 0.19
, protolude >= 0.3.3 && < 0.4
, protolude >= 0.3.3 && < 0.4
, scientific >= 0.3.7.0 && < 0.4
, scientific >= 0.3.7.0 && < 0.4
, servant >= 0.19 && < 0.20
, servant >= 0.20 && < 0.21
, servant-client >= 0.19 && < 0.20
, servant-client >= 0.20 && < 0.21
, servant-client-core >= 0.20 && < 0.21
, split >= 0.2.3.5 && < 0.3
, split >= 0.2.3.5 && < 0.3
, text >= 1.2.3.0 && < 2.1
, text >= 1.2.3.0 && < 2.1
, text-format >= 0.3.2.1 && < 0.4
, text-format >= 0.3.2.1 && < 0.4
...
@@ -100,7 +103,7 @@ executable crawlerHAL-exe
...
@@ -100,7 +103,7 @@ executable crawlerHAL-exe
, iso639 >= 0.1.0.3 && < 0.2
, iso639 >= 0.1.0.3 && < 0.2
, optparse-applicative >= 0.17 && < 0.19
, optparse-applicative >= 0.17 && < 0.19
, protolude >= 0.3.3 && < 0.4
, protolude >= 0.3.3 && < 0.4
, servant-client >= 0.
19
&& < 0.21
, servant-client >= 0.
20
&& < 0.21
, split >= 0.2.3.5 && < 0.3
, split >= 0.2.3.5 && < 0.3
, text >= 1.2.3.0 && < 2.1
, text >= 1.2.3.0 && < 2.1
default-language: Haskell2010
default-language: Haskell2010
...
...
src/HAL.hs
View file @
8bf9fc69
...
@@ -8,14 +8,14 @@ import Data.Text qualified as T
...
@@ -8,14 +8,14 @@ import Data.Text qualified as T
import
HAL.Client
(
SortField
(
Asc
),
search
,
structure
,
searchCursor
)
import
HAL.Client
(
SortField
(
Asc
),
search
,
structure
,
searchCursor
)
import
HAL.Doc.Document
(
Document
(
..
)
)
import
HAL.Doc.Document
(
Document
(
..
)
)
import
HAL.Doc.Struct
(
Struct
)
import
HAL.Doc.Struct
(
Struct
)
import
HAL.ServantClientLogging
(
addLoggingToClientEnv
)
import
HAL.Types
(
Response
(
..
))
import
HAL.Types
(
Response
(
..
))
import
HAL.Utils
(
langAbstractS
,
toText
)
import
HAL.Utils
(
langAbstractS
,
toText
)
import
Network.HTTP.Client
(
newManager
,
Request
)
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Protolude
import
Protolude
import
Servant.API
(
ToHttpApiData
)
import
Servant.API
(
ToHttpApiData
)
import
Servant.Client
(
BaseUrl
(
..
),
Scheme
(
..
),
ClientM
,
ClientError
,
runClientM
,
mkClientEnv
,
ClientEnv
(
makeClientRequest
))
import
Servant.Client
(
BaseUrl
(
..
),
Scheme
(
..
),
ClientM
,
ClientError
,
runClientM
,
mkClientEnv
)
import
System.IO.Unsafe
(
unsafePerformIO
)
data
HalCrawlerOptions
data
HalCrawlerOptions
...
@@ -237,23 +237,14 @@ baseFields = [ "docid"
...
@@ -237,23 +237,14 @@ baseFields = [ "docid"
structFields
::
Text
structFields
::
Text
structFields
=
"docid,label_s,parentDocid_i"
structFields
=
"docid,label_s,parentDocid_i"
requestLog
::
HalCrawlerOptions
->
Request
->
Request
requestLog
opts
rq
=
unsafePerformIO
$
do
debugLog
opts
$
"[HAL.makeClientRequestLog] "
<>
show
rq
pure
rq
{-# NOINLINE requestLog #-}
runHalAPIClient
::
(
FromJSON
doc
,
ToHttpApiData
doc
)
runHalAPIClient
::
(
FromJSON
doc
,
ToHttpApiData
doc
)
=>
HalCrawlerOptions
=>
HalCrawlerOptions
->
ClientM
(
Response
doc
)
->
ClientM
(
Response
doc
)
->
IO
(
Either
ClientError
(
Response
doc
))
->
IO
(
Either
ClientError
(
Response
doc
))
runHalAPIClient
opts
cmd
=
do
runHalAPIClient
_
opts
cmd
=
do
manager'
<-
newManager
tlsManagerSettings
manager'
<-
newManager
tlsManagerSettings
runClientM
cmd'
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.archives-ouvertes.fr"
443
""
)
let
env
=
mkClientEnv
manager'
$
BaseUrl
Https
"api.archives-ouvertes.fr"
443
""
where
runClientM
cmd
$
addLoggingToClientEnv
env
cmd'
=
local
(
\
r
->
r
{
makeClientRequest
=
\
bUrl
servantRq
->
requestLog
opts
(
makeClientRequest
r
bUrl
servantRq
)
})
cmd
runStructureRequest
::
Maybe
Text
->
IO
(
Either
ClientError
(
Response
Struct
))
runStructureRequest
::
Maybe
Text
->
IO
(
Either
ClientError
(
Response
Struct
))
runStructureRequest
rq
=
runStructureRequest
rq
=
...
...
src/HAL/ServantClientLogging.hs
0 → 100644
View file @
8bf9fc69
{-|
Module : HAL.ServantClientLogging
Description : Textmining Collaborative Platform
Copyright : (c) CNRS, 2023-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
@Gargantext@: search, map, share
-}
{-# LANGUAGE FlexibleContexts #-}
module
HAL.ServantClientLogging
where
import
Data.Binary.Builder
qualified
as
DBB
import
Debug.Trace
(
trace
)
import
Protolude
hiding
(
trace
)
import
Servant.Client
(
ClientEnv
(
..
))
import
Servant.Client.Core.Request
(
RequestF
(
..
))
addLoggingToClientEnv
::
ClientEnv
->
ClientEnv
addLoggingToClientEnv
env
@
(
ClientEnv
{
makeClientRequest
=
mcr
})
=
env
{
makeClientRequest
}
where
makeClientRequest
baseUrl
req
=
trace
(
"req: "
<>
showRequestPath
req
<>
" "
<>
show
(
requestQueryString
req
))
$
mcr
baseUrl
req
showRequestPath
req
=
show
$
DBB
.
toLazyByteString
$
requestPath
req
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