packages feed

hasql-pool (empty) → 0.1

raw patch · 5 files changed

+142/−0 lines, 5 filesdep +base-preludedep +hasqldep +resource-poolsetup-changed

Dependencies added: base-prelude, hasql, resource-pool, time

Files

+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2015, Nikita Volkov++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hasql-pool.cabal view
@@ -0,0 +1,56 @@+name:+  hasql-pool+version:+  0.1+category:+  Hasql, Database, PostgreSQL+synopsis:+  A pool of connections for Hasql+homepage:+  https://github.com/nikita-volkov/hasql-pool +bug-reports:+  https://github.com/nikita-volkov/hasql-pool/issues +author:+  Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer:+  Nikita Volkov <nikita.y.volkov@mail.ru>+copyright:+  (c) 2015, Nikita Volkov+license:+  MIT+license-file:+  LICENSE+build-type:+  Simple+cabal-version:+  >=1.10+++source-repository head+  type:+    git+  location:+    git://github.com/nikita-volkov/hasql-pool.git+++library+  hs-source-dirs:+    library+  ghc-options:+  default-extensions:+    Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, ImpredicativeTypes, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+  default-language:+    Haskell2010+  other-modules:+    Hasql.Pool.Prelude+  exposed-modules:+    Hasql.Pool+  build-depends:+    -- resources:+    resource-pool >= 0.2 && < 0.3,+    -- database:+    hasql >= 0.15 && < 0.16,+    -- data:+    time >= 1.4 && < 2,+    -- general:+    base-prelude >= 0.1.19 && < 0.2
+ library/Hasql/Pool.hs view
@@ -0,0 +1,48 @@+module Hasql.Pool+(+  Pool,+  acquire,+  release,+  use,+)+where++import Hasql.Pool.Prelude+import qualified Hasql.Connection+import qualified Hasql.Settings+import qualified Data.Pool+++-- |+-- A pool of connections to DB.+newtype Pool =+  Pool (Data.Pool.Pool (Either Hasql.Connection.ConnectionError Hasql.Connection.Connection))++-- |+-- Given the pool-size, timeout and connection settings+-- create a connection-pool.+acquire :: Int -> NominalDiffTime -> Hasql.Settings.Settings -> IO Pool+acquire size timeout connectionSettings =+  fmap Pool $+  Data.Pool.createPool acquire release stripes timeout size+  where+    acquire =+      Hasql.Connection.acquire connectionSettings+    release =+      either (const (pure ())) Hasql.Connection.release+    stripes =+      1++-- |+-- Release the connection-pool.+release :: Pool -> IO ()+release (Pool pool) =+  Data.Pool.destroyAllResources pool++-- |+-- Use a connection from the pool and return it to the pool, when finished.+-- Exception-safe.+use :: Pool -> (Hasql.Connection.Connection -> IO a) -> IO (Either Hasql.Connection.ConnectionError a)+use (Pool pool) handler =+  Data.Pool.withResource pool (traverse handler)+
+ library/Hasql/Pool/Prelude.hs view
@@ -0,0 +1,14 @@+module Hasql.Pool.Prelude+( +  module Exports,+)+where+++-- base-prelude+-------------------------+import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, error)++-- time+-------------------------+import Data.Time as Exports