Skip to content

Commit

Permalink
Merge minor into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Mar 7, 2024
2 parents 81f4fb0 + 48f9b1c commit 497adbd
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 164 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Compile, test and check the docs

on:
workflow_call:

jobs:

check:

strategy:
fail-fast: false
matrix:
include:
- ghc: 8.8.1
ghc-options: ""
ignore-haddock: true
ignore-cabal-check: true
- ghc: latest
ignore-cabal-check: true

runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:

- uses: nikita-volkov/build-and-test-cabal-package.github-action@v1
with:
ghc: ${{matrix.ghc}}
ghc-options: ${{matrix.ghc-options}}
ignore-haddock: ${{matrix.ignore-haddock}}
ignore-cabal-check: ${{matrix.ignore-cabal-check}}
17 changes: 17 additions & 0 deletions .github/workflows/on-push-to-master-or-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Compile, test and check the docs

on:
push:
branches:
- master
pull_request:

jobs:

format:
uses: nikita-volkov/haskell-hackage-lib-github-actions-workflows/.github/workflows/format.yaml@v3
secrets: inherit

check:
uses: ./.github/workflows/check.yaml
secrets: inherit
32 changes: 32 additions & 0 deletions .github/workflows/on-push-to-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release the lib to Hackage

on:
push:
branches:
- supermajor
- major
- minor
- patch

concurrency:
group: release
cancel-in-progress: false

jobs:

format:
uses: nikita-volkov/haskell-hackage-lib-github-actions-workflows/.github/workflows/format.yaml@v3
secrets: inherit

check:
uses: ./.github/workflows/check.yaml
secrets: inherit

release:
needs:
- format
- check
uses: nikita-volkov/haskell-hackage-lib-github-actions-workflows/.github/workflows/release.yaml@v3
secrets: inherit
with:
prefix-tag-with-v: false
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
68 changes: 53 additions & 15 deletions hasql-cursor-transaction.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cabal-version: 3.0
name: hasql-cursor-transaction
version: 0.6.4
version: 0.6.5
category: Hasql, Database, PostgreSQL, Streaming
synopsis: An abstraction for simultaneous fetching from multiple PostgreSQL cursors
homepage: https://github.com/nikita-volkov/hasql-cursor-transaction
Expand All @@ -9,30 +10,67 @@ maintainer: Nikita Volkov <[email protected]>
copyright: (c) 2016, Nikita Volkov
license: MIT
license-file: LICENSE
build-type: Simple
cabal-version: >=1.10

library
hs-source-dirs: library
default-extensions: Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples
default-language: Haskell2010
default-extensions:
Arrows
BangPatterns
ConstraintKinds
DataKinds
DefaultSignatures
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveTraversable
EmptyDataDecls
FlexibleContexts
FlexibleInstances
FunctionalDependencies
GADTs
GeneralizedNewtypeDeriving
LambdaCase
LiberalTypeSynonyms
MagicHash
MultiParamTypeClasses
MultiWayIf
NoImplicitPrelude
NoMonomorphismRestriction
OverloadedStrings
ParallelListComp
PatternGuards
QuasiQuotes
RankNTypes
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
TemplateHaskell
TupleSections
TypeFamilies
TypeOperators
UnboxedTuples

other-modules:
Hasql.CursorTransaction.Private.CursorTransaction
Hasql.CursorTransaction.Private.Prelude
Hasql.CursorTransaction.Private.Statements
Hasql.CursorTransaction.Private.Specs
Hasql.CursorTransaction.Private.Statements
Hasql.CursorTransaction.Private.Transactions
Hasql.CursorTransaction.Private.CursorTransaction

exposed-modules:
Hasql.CursorTransaction.Transactions
Hasql.CursorTransaction.Sessions
Hasql.CursorTransaction
Hasql.CursorTransaction.Sessions
Hasql.CursorTransaction.Transactions

build-depends:
base >=4.9 && <5,
base-prelude >=1 && <2,
bytestring >=0.10 && <0.11,
bytestring-tree-builder ==0.2.*,
contravariant >=1.3 && <2,
contravariant-extras >=0.3.3.1 && <0.4,
hasql >=1.4 && <1.5,
hasql-transaction >=0.7 && <0.8,
transformers >=0.4 && <0.6
bytestring >=0.10 && <0.14,
bytestring-tree-builder >=0.2 && <0.3,
contravariant >=1.5 && <2,
contravariant-extras >=0.3.5.4 && <0.4,
hasql ^>=1.6.4.1,
hasql-transaction ^>=1.1,
transformers >=0.4 && <0.7,
39 changes: 20 additions & 19 deletions library/Hasql/CursorTransaction.hs
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
module Hasql.CursorTransaction
(
-- * Types
A.CursorTransaction,
A.Cursor,
B.BatchSize,
B.EncodedParams,
-- * Cursor Transactions
A.declareCursor,
A.fetchBatch,
A.transaction,
-- * Batch Sizes
B.batchSize_10,
B.batchSize_100,
B.batchSize_1000,
B.batchSize_10000,
-- * Encoded Params
B.encodedParams,
)
( -- * Types
A.CursorTransaction,
A.Cursor,
B.BatchSize,
B.EncodedParams,

-- * Cursor Transactions
A.declareCursor,
A.fetchBatch,
A.transaction,

-- * Batch Sizes
B.batchSize_10,
B.batchSize_100,
B.batchSize_1000,
B.batchSize_10000,

-- * Encoded Params
B.encodedParams,
)
where

import qualified Hasql.CursorTransaction.Private.CursorTransaction as A
import qualified Hasql.CursorTransaction.Private.Specs as B

45 changes: 22 additions & 23 deletions library/Hasql/CursorTransaction/Private/CursorTransaction.hs
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
module Hasql.CursorTransaction.Private.CursorTransaction
where
module Hasql.CursorTransaction.Private.CursorTransaction where

import qualified ByteString.TreeBuilder as E
import Hasql.CursorTransaction.Private.Prelude
import qualified Hasql.Transaction as A
import qualified Hasql.Encoders as D
import qualified Hasql.Decoders as F
import qualified Hasql.CursorTransaction.Private.Transactions as C
import qualified Hasql.CursorTransaction.Private.Specs as G
import qualified ByteString.TreeBuilder as E

import qualified Hasql.CursorTransaction.Private.Transactions as C
import qualified Hasql.Decoders as F
import qualified Hasql.Encoders as D
import qualified Hasql.Transaction as A

-- |
-- Context for fetching from multiple cursors in an intertwined fashion.
newtype CursorTransaction s result =
CursorTransaction (StateT (Int, A.Transaction ()) A.Transaction result)
newtype CursorTransaction s result
= CursorTransaction (StateT (Int, A.Transaction ()) A.Transaction result)
deriving (Functor, Applicative, Monad)

-- |
-- Cursor reference.
newtype Cursor s =
Cursor ByteString
newtype Cursor s
= Cursor ByteString

-- |
-- Given a template and encoded params produces a cursor,
-- while automating its resource management.
declareCursor :: ByteString -> G.EncodedParams -> CursorTransaction s (Cursor s)
declareCursor template (G.EncodedParams (Supplied encoder params)) =
CursorTransaction $
do
name <- state $ do
(inc, finaliser) <- id
name <- return (incToName inc)
newFinaliser <- return (finaliser *> C.closeCursor name)
return (name, (succ inc, newFinaliser))
lift (C.declareCursor name template encoder params)
return (Cursor name)
CursorTransaction
$ do
name <- state $ do
(inc, finaliser) <- id
name <- return (incToName inc)
newFinaliser <- return (finaliser *> C.closeCursor name)
return (name, (succ inc, newFinaliser))
lift (C.declareCursor name template encoder params)
return (Cursor name)
where
incToName inc =
E.toByteString $
E.byteString "Hasql_CursorTransaction_" <> E.asciiIntegral inc
E.toByteString
$ E.byteString "Hasql_CursorTransaction_"
<> E.asciiIntegral inc

-- |
-- Fetch from a cursor a batch of the given size and decode it using the specified result decoder.
Expand Down
28 changes: 6 additions & 22 deletions library/Hasql/CursorTransaction/Private/Prelude.hs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
module Hasql.CursorTransaction.Private.Prelude
(
module Exports,
)
( module Exports,
)
where


-- base-prelude
-------------------------
import BasePrelude as Exports hiding (assert, left, right, isLeft, isRight, error)

-- transformers
-------------------------
import BasePrelude as Exports hiding (assert, error, isLeft, isRight, left, right)
import Contravariant.Extras as Exports
import Control.Monad.IO.Class as Exports
import Control.Monad.Trans.Class as Exports
import Control.Monad.Trans.Cont as Exports hiding (shift)
Expand All @@ -19,17 +13,7 @@ import Control.Monad.Trans.Maybe as Exports hiding (liftCallCC, liftCatch, liftP
import Control.Monad.Trans.Reader as Exports hiding (liftCallCC)
import Control.Monad.Trans.State.Strict as Exports hiding (liftCatch, liftListen, liftPass)
import Control.Monad.Trans.Writer.Strict as Exports hiding (liftCallCC, liftCatch)
import Data.Functor.Identity as Exports

-- contravariant
-------------------------
import Data.ByteString as Exports (ByteString)
import Data.Functor.Contravariant as Exports
import Data.Functor.Contravariant.Divisible as Exports

-- contravariant-extras
-------------------------
import Contravariant.Extras as Exports

-- bytestring
-------------------------
import Data.ByteString as Exports (ByteString)
import Data.Functor.Identity as Exports
Loading

0 comments on commit 497adbd

Please sign in to comment.