-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Yet another redis client.
--   
--   Yet another redis client.
@package redis-io
@version 0.7.0

module Database.Redis.IO

-- | Redis client monad.
data Client a

-- | Monads in which <a>Client</a> actions may be embedded.
class (Functor m, Applicative m, Monad m, MonadIO m, MonadCatch m) => MonadClient m

-- | Lift a computation to the <a>Client</a> monad.
liftClient :: MonadClient m => Client a -> m a
runRedis :: MonadIO m => Pool -> Client a -> m a

-- | Execute the given redis commands pipelined, i.e. commands are send in
--   batches to the server and the responses are fetched and parsed after a
--   full batch has been sent. A failing command which produces a
--   <a>RedisError</a> will <i>not</i> prevent subsequent commands from
--   being executed by the redis server. However the first error will be
--   thrown as an exception. To force sending see <a>sync</a>.
commands :: MonadClient m => Redis IO a -> m a

-- | Execute the given publish/subscribe commands. The first parameter is
--   the callback function which will be invoked with a possible pattern
--   (if <tt>PSUBSCRIBE</tt> was used), channel, and message, once messages
--   arrive.
pubSub :: MonadClient m => (Maybe ByteString -> ByteString -> ByteString -> PubSub IO ()) -> PubSub IO () -> m ()
sync :: Redis IO a -> Redis IO a

-- | Connection pool.
data Pool
mkPool :: MonadIO m => Logger -> Settings -> m Pool
shutdown :: MonadIO m => Pool -> m ()
data Settings

-- | Default settings.
--   
--   <ul>
--   <li>host = localhost</li>
--   <li>port = 6379</li>
--   <li>idle timeout = 60s</li>
--   <li>stripes = 2</li>
--   <li>connections per stripe = 25</li>
--   <li>connect timeout = 5s</li>
--   <li>send-receive timeout = 10s</li>
--   </ul>
defSettings :: Settings
setHost :: String -> Settings -> Settings
setPort :: Word16 -> Settings -> Settings
setIdleTimeout :: NominalDiffTime -> Settings -> Settings

-- | Maximum connections per pool stripe.
setMaxConnections :: Int -> Settings -> Settings
setPoolStripes :: Int -> Settings -> Settings

-- | When a pool connection is opened, connect timeout is the maximum time
--   we are willing to wait for the connection attempt to the redis server
--   to succeed.
setConnectTimeout :: NominalDiffTime -> Settings -> Settings
setSendRecvTimeout :: NominalDiffTime -> Settings -> Settings
data ConnectionError

-- | All connections are in use.
ConnectionsBusy :: ConnectionError

-- | The connection has been closed unexpectedly.
ConnectionClosed :: ConnectionError

-- | Connecting to redis server took too long.
ConnectTimeout :: ConnectionError

-- | General error, e.g. parsing redis responses failed.
newtype InternalError
InternalError :: String -> InternalError

-- | A single send-receive cycle took too long.
newtype Timeout
Timeout :: String -> Timeout

-- | An exception thrown on transaction failures.
data TransactionFailure

-- | A <tt>WATCH</tt>ed key changed conccurrently.
TransactionAborted :: TransactionFailure

-- | The transaction was <tt>DISCARD</tt>ed.
TransactionDiscarded :: TransactionFailure

-- | Other transaction failure.
TransactionFailure :: String -> TransactionFailure
