Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow Pool.withConnection to work with monads other than IO #10

Open
wants to merge 3 commits into from

3 participants

@whittle

Bumps the resource-pool dependency from >=0.1.0.2 to >=0.2.0.4 to allow withConnection to operate within any monad in MonadBaseControl IO.

Also adds cabal hooks for the test suite.

@IreneKnapp

It would be great if this could get merged!

@pheaver

I don't believe Janrain is maintaining this package anymore.

@IreneKnapp

Thank you for the information. If that's the case, then it appears to be unmaintained, which is an unpleasant surprise.

@markhibberd markhibberd referenced this pull request from a commit in markhibberd/riak-haskell-client
@markhibberd markhibberd Merge in a variation on janrain/riak-haskell-client#10. b25712b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 10 deletions.
  1. +1 −0  .gitignore
  2. +20 −5 riak.cabal
  3. +6 −5 src/Network/Riak/Connection/Pool.hs
View
1  .gitignore
@@ -0,0 +1 @@
+dist*
View
25 riak.cabal
@@ -53,7 +53,7 @@ flag developer
library
hs-source-dirs: src
- exposed-modules:
+ exposed-modules:
Network.Riak
Network.Riak.Basic
Network.Riak.Connection
@@ -71,14 +71,14 @@ library
Network.Riak.Value
Network.Riak.Value.Resolvable
- other-modules:
+ other-modules:
Network.Riak.Connection.Internal
Network.Riak.Connection.NoPush
Network.Riak.Resolvable.Internal
Network.Riak.Tag
Network.Riak.Types.Internal
-
- build-depends:
+
+ build-depends:
aeson >= 0.3.2.4,
attoparsec >= 0.8.5.3,
base == 4.*,
@@ -86,8 +86,9 @@ library
blaze-builder,
bytestring,
containers,
+ monad-control >= 0.2.0.1,
network >= 2.3,
- resource-pool >= 0.1.0.2,
+ resource-pool >= 0.2.0.4,
protocol-buffers >= 2.0.5,
pureMD5,
random,
@@ -105,6 +106,20 @@ library
ghc-options: -Wall
+test-suite test
+ type: exitcode-stdio-1.0
+ main-is: Properties.hs
+ hs-source-dirs: tests
+ ghc-options: -Wall
+
+ build-depends:
+ riak,
+ base,
+ bytestring,
+ QuickCheck,
+ test-framework,
+ test-framework-quickcheck2
+
source-repository head
type: git
location: http://github.com/bos/riak-haskell-client
View
11 src/Network/Riak/Connection/Pool.hs
@@ -1,5 +1,5 @@
-{-# LANGUAGE DeriveDataTypeable, NamedFieldPuns, RecordWildCards,
- ScopedTypeVariables #-}
+{-# LANGUAGE DeriveDataTypeable, FlexibleContexts,
+ NamedFieldPuns, RecordWildCards, ScopedTypeVariables #-}
-- |
-- Module: Network.Riak.Connection.Pool
@@ -23,6 +23,7 @@ module Network.Riak.Connection.Pool
, withConnection
) where
+import Control.Monad.Trans.Control (MonadBaseControl)
import Data.Time.Clock (NominalDiffTime)
import Data.Typeable (Typeable)
import Network.Riak (Client(clientID), Connection, connect, disconnect)
@@ -69,7 +70,7 @@ create :: Client
-> Int
-- ^ Maximum number of connections to keep open per stripe.
-- The smallest acceptable value is 1.
- --
+ --
-- Requests for connections will block if this limit is reached
-- on a single stripe, even if other stripes have idle
-- connections available.
@@ -95,7 +96,7 @@ idleTime = Pool.idleTime . pool
-- | Maximum number of connections to keep open per stripe. The
-- smallest acceptable value is 1.
---
+--
-- Requests for connections will block if this limit is reached on a
-- single stripe, even if other stripes have idle connections
-- available.
@@ -121,5 +122,5 @@ maxConnections = Pool.maxResources . pool
-- It probably goes without saying that you should never call
-- 'disconnect' on a connection, as doing so will cause a subsequent
-- user (who expects the connection to be valid) to throw an exception.
-withConnection :: Pool -> (Connection -> IO a) -> IO a
+withConnection :: MonadBaseControl IO m => Pool -> (Connection -> m a) -> m a
withConnection = Pool.withResource . pool
Something went wrong with that request. Please try again.