From 0403b19a44093054f33560747780aa7724180273 Mon Sep 17 00:00:00 2001 From: Chris Allen Date: Wed, 6 Jul 2016 15:33:39 -0500 Subject: [PATCH] http-client-0.5.0 support --- Makefile | 23 +++++------------------ bloodhound.cabal | 4 ++-- src/Database/Bloodhound/Client.hs | 14 ++++++++------ stack-7.10.yaml | 3 ++- tests/tests.hs | 3 ++- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index c7eefca..3742ab2 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,9 @@ -install-with-test-support: - cabal install --enable-tests - echo "Make certain you have an elasticsearch instance on localhost:9200 !" - cabal test +build: + stack build test: echo "Make certain you have an elasticsearch instance on localhost:9200 !" - cabal clean - cabal test + stack test -build: - cabal build - -test-repl: - cabal repl tests - -repl: - cabal repl - -reset: - rm -rf .cabal-sandbox - cabal sandbox init +ghci: + stack ghci diff --git a/bloodhound.cabal b/bloodhound.cabal index e6bfc2b..0104a58 100644 --- a/bloodhound.cabal +++ b/bloodhound.cabal @@ -1,5 +1,5 @@ name: bloodhound -version: 0.11.0.0 +version: 0.11.1.0 synopsis: ElasticSearch client library for Haskell description: ElasticSearch made awesome for Haskell hackers homepage: https://github.com/bitemyapp/bloodhound @@ -33,7 +33,7 @@ library bytestring >= 0.10.0 && <0.11, containers >= 0.5.0.0 && <0.6, aeson >= 0.11.1 && <0.12, - http-client >= 0.3 && <0.5, + http-client >= 0.5 && <0.6, network-uri >= 2.6 && <2.7, semigroups >= 0.15 && <0.19, time >= 1.4 && <1.7, diff --git a/src/Database/Bloodhound/Client.hs b/src/Database/Bloodhound/Client.hs index 8c84f10..98b2d3f 100644 --- a/src/Database/Bloodhound/Client.hs +++ b/src/Database/Bloodhound/Client.hs @@ -176,15 +176,17 @@ mkReplicaCount n emptyBody :: L.ByteString emptyBody = L.pack "" -dispatch :: MonadBH m => Method -> Text -> Maybe L.ByteString - -> m Reply +dispatch :: MonadBH m + => Method + -> Text + -> Maybe L.ByteString + -> m Reply dispatch dMethod url body = do initReq <- liftIO $ parseUrl' url reqHook <- bhRequestHook <$> getBHEnv let reqBody = RequestBodyLBS $ fromMaybe emptyBody body - req <- liftIO $ reqHook $ initReq { method = dMethod - , requestBody = reqBody - , checkStatus = \_ _ _ -> Nothing} + req <- liftIO $ reqHook $ setRequestIgnoreStatus $ initReq { method = dMethod + , requestBody = reqBody } mgr <- bhManager <$> getBHEnv liftIO $ httpLbs req mgr @@ -828,7 +830,7 @@ pageSearch :: From -- ^ The result offset pageSearch resultOffset pageSize search = search { from = resultOffset, size = pageSize } parseUrl' :: MonadThrow m => Text -> m Request -parseUrl' t = parseUrl (URI.escapeURIString URI.isAllowedInURI (T.unpack t)) +parseUrl' t = parseRequest (URI.escapeURIString URI.isAllowedInURI (T.unpack t)) -- | Was there an optimistic concurrency control conflict when -- indexing a document? diff --git a/stack-7.10.yaml b/stack-7.10.yaml index 0fef23b..1e93b76 100644 --- a/stack-7.10.yaml +++ b/stack-7.10.yaml @@ -2,10 +2,11 @@ flags: {} packages: - '.' extra-deps: +# - http-client-0.4.24 +- http-client-0.5.0 - aeson-0.11.1.0 - fail-4.9.0.0 - http-types-0.9 -- http-client-0.4.24 - attoparsec-0.13.0.1 - doctest-0.10.1 - doctest-prop-0.2.0.1 diff --git a/tests/tests.hs b/tests/tests.hs index a22f2d3..95e15af 100644 --- a/tests/tests.hs +++ b/tests/tests.hs @@ -1154,6 +1154,7 @@ main = hspec $ do searchExpectAggs search searchValidBucketAgg search "users" toTerms + -- One of these fails with 1.7.3 it "can give execution hint parameters to term aggregations" $ when' (atmost es11) $ withTestEnv $ do _ <- insertData searchTermsAggHint [Map, Ordinals] @@ -1165,7 +1166,7 @@ main = hspec $ do it "can give execution hint parameters to term aggregations" $ when' (atleast es12) $ withTestEnv $ do _ <- insertData searchTermsAggHint [GlobalOrdinals, GlobalOrdinalsHash, GlobalOrdinalsLowCardinality, Map] - + -- One of the above. it "can execute value_count aggregations" $ withTestEnv $ do _ <- insertData