Skip to content

Commit

Permalink
creating a RedisTimeoutException, but still defaulting to NoNodeExcep…
Browse files Browse the repository at this point in the history
…tion for now
  • Loading branch information
shashitnak committed Apr 10, 2023
1 parent a12130c commit 4b7190e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Database/Redis/Cluster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ instance Exception CrossSlotException
data NoNodeException = NoNodeException deriving (Show, Typeable)
instance Exception NoNodeException

data BusyNodeException = BusyNodeException deriving (Show, Typeable)
instance Exception BusyNodeException

data RedisTimeoutException e = TimeoutException e deriving (Show, Typeable)
instance (Show e, Typeable e) => Exception (RedisTimeoutException e)

timeoutDueTo :: (Exception e, Show e, Typeable e) => e -> RedisTimeoutException e
timeoutDueTo = TimeoutException

connect :: (Host -> CC.PortID -> Maybe Int -> IO CC.ConnectionContext) -> [CMD.CommandInfo] -> MVar ShardMap -> Maybe Int -> Bool -> ([NodeConnection] -> IO ShardMap) -> Time.NominalDiffTime -> Int -> IO Connection
connect withAuth commandInfos shardMapVar timeoutOpt isReadOnly refreshShardMap idleTime maxResources = do
shardMap <- readMVar shardMapVar
Expand Down Expand Up @@ -447,7 +456,7 @@ requestNode (NodeConnection pool lastRecvRef nid) requests = withResource pool $
eresp <- race (requestNodeImpl ctx) (threadDelay envTimeout)
case eresp of
Left e -> return e
Right _ -> putStrLn ("timeout happened" ++ show nid) *> throwIO NoNodeException
Right _ -> putStrLn ("timeout happened" ++ show nid) *> (throwIO $ timeoutDueTo NoNodeException)
where
requestNodeImpl :: CC.ConnectionContext -> IO [Reply]
requestNodeImpl ctx = do
Expand Down

0 comments on commit 4b7190e

Please sign in to comment.