-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Periodic.ClientPool | ||
( | ||
module Periodic.Client | ||
, ClientEnv | ||
, runClientT | ||
, open | ||
) where | ||
|
||
import Data.Pool (Pool, createPool, withResource) | ||
import Periodic.Client hiding (ClientEnv, close, open, runClientT) | ||
import qualified Periodic.Client as Client (ClientEnv, close, open, | ||
runClientT) | ||
import Periodic.Transport (Transport) | ||
|
||
type ClientEnv = Pool (Client.ClientEnv IO) | ||
|
||
runClientT :: ClientEnv -> ClientT IO a -> IO a | ||
runClientT pool m = withResource pool $ flip Client.runClientT m | ||
|
||
open | ||
:: (Transport -> IO Transport) -> String -> Int -> IO ClientEnv | ||
open f h = | ||
createPool (Client.open f h) (`Client.runClientT` Client.close) 1 5000 |