Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client: eject pending fetches upon disconnection #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
write-ghc-environment-files: never
packages: .

source-repository-package
type: git
tag: c32bb908a29c01a7727b8d0c7f23c1d3d63849f2
location: [email protected]:fumieval/concurrent-resource-map
4 changes: 3 additions & 1 deletion src/Database/Franz/Client.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE LambdaCase, OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
module Database.Franz.Client
Expand Down Expand Up @@ -68,7 +69,7 @@ import System.IO.Temp
-- | ---- RawClean j ----> |
-- | ---- RawClean k ----> |

newtype ConnStateMap v = ConnStateMap (IM.IntMap v)
newtype ConnStateMap v = ConnStateMap (IM.IntMap v) deriving Foldable

instance ResourceMap ConnStateMap where
type Key ConnStateMap = Int
Expand Down Expand Up @@ -165,6 +166,7 @@ connect (LocalFranzPath path) = do

disconnect :: Connection -> IO ()
disconnect Connection{..} = do
foreachResource connStates $ \mr -> forM_ mr $ \v -> atomically $ writeTVar v $ Errored $ ClientError "disconnect"
killThread connThread
withMVar connSocket S.close
disconnect LocalConnection{..} =
Expand Down