packages feed

hedis 0.9.3 → 0.9.4

raw patch · 4 files changed

+32/−12 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.Redis: checkedConnect :: ConnectInfo -> IO Connection

Files

hedis.cabal view
@@ -1,5 +1,5 @@ name:               hedis-version:            0.9.3+version:            0.9.4 synopsis:     Client library for the Redis datastore: supports full command set,     pipelining.
src/Database/Redis.hs view
@@ -5,7 +5,7 @@     --     -- @     -- -- connects to localhost:6379-    -- conn <- 'connect' 'defaultConnectInfo'+    -- conn <- 'checkedConnect' 'defaultConnectInfo'     -- @     --     -- Send commands to the server:@@ -122,6 +122,14 @@     --    functions throw a 'ConnectionLostException'. It can only be caught     --    outside of 'runRedis'.     --+    --  [Trying to connect to an unreachable server:] When trying to connect to+    --    a server that does not exist or can't be reached, the connection pool+    --    only starts the first connection when actually executing a call to+    --    the server. This can lead to discovering very late that the server is+    --    not available, for example when running a server that logs to Redis.+    --    To prevent this, run a 'ping' command directly after connecting or+    --    use the 'checkedConnect' function which encapsulates this behavior.+    --     --  [Exceptions:] Any exceptions can only be caught /outside/ of 'runRedis'.     --    This way the connection pool can properly close the connection, making     --    sure it is not left in an unusable state, e.g. closed or inside a@@ -134,7 +142,7 @@     RedisCtx(), MonadRedis(..),      -- * Connection-    Connection, connect,+    Connection, connect, checkedConnect,     ConnectInfo(..),defaultConnectInfo,     HostName,PortID(..),     
src/Database/Redis/Commands.hs view
@@ -537,11 +537,6 @@     -> m (f Integer) sinterstore destination key = sendRequest (["SINTERSTORE"] ++ [encode destination] ++ map encode key ) -ping-    :: (RedisCtx m f)-    => m (f Status)-ping  = sendRequest (["PING"] )- hvals     :: (RedisCtx m f)     => ByteString -- ^ key
src/Database/Redis/Core.hs view
@@ -2,12 +2,12 @@     MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, CPP #-}  module Database.Redis.Core (-    Connection(..), connect,+    Connection(..), connect, checkedConnect,     ConnectInfo(..), defaultConnectInfo,     Redis(), runRedis, unRedis, reRedis,     RedisCtx(..), MonadRedis(..),     send, recv, sendRequest,-    auth, select+    auth, select, ping ) where  import Prelude@@ -189,8 +189,9 @@     , connectMaxIdleTime    = 30     } --- |Opens a 'Connection' to a Redis server designated by the given---  'ConnectInfo'.+-- |Constructs a 'Connection' pool to a Redis server designated by the +--  given 'ConnectInfo'. The first connection is not actually established+--  until the first call to the server. connect :: ConnectInfo -> IO Connection connect ConnInfo{..} = Conn <$>     createPool create destroy 1 connectMaxIdleTime connectMaxConnections@@ -208,6 +209,16 @@      destroy = PP.disconnect +-- |Constructs a 'Connection' pool to a Redis server designated by the+--  given 'ConnectInfo', then tests if the server is actually there. +--  Throws an exception if the connection to the Redis server can't be+--  established.+checkedConnect :: ConnectInfo -> IO Connection+checkedConnect connInfo = do+    conn <- connect connInfo+    runRedis conn $ void ping+    return conn+ -- The AUTH command. It has to be here because it is used in 'connect'. auth     :: B.ByteString -- ^ password@@ -220,3 +231,9 @@     => Integer -- ^ index     -> m (f Status) select ix = sendRequest ["SELECT", encode ix]++-- The PING command. Used in 'checkedConnect'.+ping+    :: (RedisCtx m f)+    => m (f Status)+ping  = sendRequest (["PING"] )