{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Database.Redis.ManualCommands.Wait
( WaitAofResult(..)
, wait
, waitaof
) where
import Database.Redis.Core
import Database.Redis.Types
data WaitAofResult = WaitAofResult
{ WaitAofResult -> Integer
waitAofLocal :: Integer
, WaitAofResult -> Integer
waitAofReplicas :: Integer
} deriving (Int -> WaitAofResult -> ShowS
[WaitAofResult] -> ShowS
WaitAofResult -> String
(Int -> WaitAofResult -> ShowS)
-> (WaitAofResult -> String)
-> ([WaitAofResult] -> ShowS)
-> Show WaitAofResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WaitAofResult -> ShowS
showsPrec :: Int -> WaitAofResult -> ShowS
$cshow :: WaitAofResult -> String
show :: WaitAofResult -> String
$cshowList :: [WaitAofResult] -> ShowS
showList :: [WaitAofResult] -> ShowS
Show, WaitAofResult -> WaitAofResult -> Bool
(WaitAofResult -> WaitAofResult -> Bool)
-> (WaitAofResult -> WaitAofResult -> Bool) -> Eq WaitAofResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: WaitAofResult -> WaitAofResult -> Bool
== :: WaitAofResult -> WaitAofResult -> Bool
$c/= :: WaitAofResult -> WaitAofResult -> Bool
/= :: WaitAofResult -> WaitAofResult -> Bool
Eq)
instance RedisResult WaitAofResult where
decode :: Reply -> Either Reply WaitAofResult
decode Reply
response = do
(waitAofLocal, waitAofReplicas) <- Reply -> Either Reply (Integer, Integer)
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
response
pure WaitAofResult{..}
wait
:: (RedisCtx m f)
=> Integer
-> Integer
-> m (f Integer)
wait :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> Integer -> m (f Integer)
wait Integer
numReplicas Integer
timeout =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"WAIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numReplicas, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout]
waitaof
:: (RedisCtx m f)
=> Integer
-> Integer
-> Integer
-> m (f WaitAofResult)
waitaof :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> Integer -> Integer -> m (f WaitAofResult)
waitaof Integer
numLocal Integer
numReplicas Integer
timeout =
[ByteString] -> m (f WaitAofResult)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"WAITAOF", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numLocal, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numReplicas, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout]