Hello community,

here is the log from the commit of package ghc-hedis for openSUSE:Factory 
checked in at 2016-11-10 13:29:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-hedis (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-hedis.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-hedis"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-hedis/ghc-hedis.changes      2016-11-03 
11:13:52.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-hedis.new/ghc-hedis.changes 2016-11-10 
13:29:51.000000000 +0100
@@ -1,0 +2,5 @@
+Tue Oct 11 08:49:38 UTC 2016 - [email protected]
+
+- Update to version 0.9.4 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  hedis-0.9.3.tar.gz

New:
----
  hedis-0.9.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-hedis.spec ++++++
--- /var/tmp/diff_new_pack.3PqdSB/_old  2016-11-10 13:29:52.000000000 +0100
+++ /var/tmp/diff_new_pack.3PqdSB/_new  2016-11-10 13:29:52.000000000 +0100
@@ -19,7 +19,7 @@
 %global pkg_name hedis
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.9.3
+Version:        0.9.4
 Release:        0
 Summary:        Client library for the Redis datastore: supports full command 
set, pipelining
 License:        BSD-3-Clause

++++++ hedis-0.9.3.tar.gz -> hedis-0.9.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hedis-0.9.3/hedis.cabal new/hedis-0.9.4/hedis.cabal
--- old/hedis-0.9.3/hedis.cabal 2016-08-07 14:02:17.000000000 +0200
+++ new/hedis-0.9.4/hedis.cabal 2016-10-05 22:15:07.000000000 +0200
@@ -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.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hedis-0.9.3/src/Database/Redis/Commands.hs 
new/hedis-0.9.4/src/Database/Redis/Commands.hs
--- old/hedis-0.9.3/src/Database/Redis/Commands.hs      2016-05-31 
19:29:19.000000000 +0200
+++ new/hedis-0.9.4/src/Database/Redis/Commands.hs      2016-10-05 
22:14:41.000000000 +0200
@@ -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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hedis-0.9.3/src/Database/Redis/Core.hs 
new/hedis-0.9.4/src/Database/Redis/Core.hs
--- old/hedis-0.9.3/src/Database/Redis/Core.hs  2016-08-07 13:21:06.000000000 
+0200
+++ new/hedis-0.9.4/src/Database/Redis/Core.hs  2016-10-05 22:14:41.000000000 
+0200
@@ -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"] )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hedis-0.9.3/src/Database/Redis.hs 
new/hedis-0.9.4/src/Database/Redis.hs
--- old/hedis-0.9.3/src/Database/Redis.hs       2016-05-05 15:33:10.000000000 
+0200
+++ new/hedis-0.9.4/src/Database/Redis.hs       2016-10-05 22:14:41.000000000 
+0200
@@ -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(..),
     


Reply via email to