@hackage valiant-conduit0.1.0.0

Conduit streaming adapter for valiant

  • Installation

  • Tested Compilers

  • Dependencies (3)

  • Dependents (0)

  • Package Flags

      werror
       (off by default)

      Enable -Werror for development builds.

valiant-conduit

Conduit streaming adapter for valiant.

Produces ConduitT () r IO () values from query results, so query output composes with the rest of the conduit ecosystem.

Quick start

import Valiant
import Valiant.Conduit
import Conduit

countActiveUsers :: Pool -> IO Int
countActiveUsers pool =
  withTransaction pool $ \tx ->
    runConduit $
      selectSource (txConn tx) listAllUsers () 500
      .| filterC userActive
      .| lengthC

Two streaming strategies

  • selectSource conn stmt params batchSize — cursor-based. Must run inside a transaction. Fetches in batches of batchSize rows.
  • foldSource conn stmt params — single-shot extended-protocol query. No transaction required.

Both functions accumulate one result set at a time before yielding, so memory usage scales with the active batch (cursor) or the full result set (foldSource). For truly incremental memory use across a large cursor, drive Valiant.withCursor / Valiant.fetchBatch yourself.

See the valiant tutorial for Statement definitions and the valiant prepare workflow.