Skip to content

Commit

Permalink
fix(connector): catch zk exception in handleConnectorRequest (#1624)
Browse files Browse the repository at this point in the history
  • Loading branch information
s12f authored Sep 27, 2023
1 parent 64c932c commit 810eb7f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hstream-io/HStream/IO/IOTask.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import qualified HStream.Stats as Stats
import qualified HStream.Utils as Utils
import System.Directory (createDirectoryIfMissing)
import qualified System.Process.Typed as TP
import qualified ZooKeeper.Exception as E

newIOTask :: T.Text -> M.MetaHandle -> Stats.StatsHolder -> TaskInfo -> T.Text -> IOOptions -> IO IOTask
newIOTask taskId taskHandle taskStatsHolder taskInfo path ioOptions = do
Expand Down Expand Up @@ -111,7 +112,11 @@ handleStdout ioTask hStdout hStdin = forever $ do

handleConnectorRequest :: IOTask -> MSG.ConnectorRequest -> IO MSG.ConnectorResponse
handleConnectorRequest ioTask MSG.ConnectorRequest{..} = do
MSG.ConnectorResponse crId <$> handleConnectorMessage ioTask crMessage
MSG.ConnectorResponse crId <$> E.catch
(handleConnectorMessage ioTask crMessage)
(\(e :: E.ZooException) -> do
Log.warning $ "handleConnectorRequest failed:" <> Log.buildString (show e) <> "ignored"
pure J.Null)

handleConnectorMessage :: IOTask -> MSG.ConnectorMessage -> IO J.Value
handleConnectorMessage IOTask{..} (MSG.KvGet MSG.KvGetMessage{..}) = J.toJSON <$> M.getTaskKv taskHandle taskId kgKey
Expand Down

0 comments on commit 810eb7f

Please sign in to comment.