glimr_sqlite/db/pool

SQLite connection pool management.

Provides connection pooling for SQLite databases. Pools manage a set of reusable connections and handle checkout/ checkin automatically through the get_connection function.

Types

A SQLite database connection. Obtained through get_connection and should not be stored or used outside the callback. This is an alias for the underlying sqlight.Connection type.

pub type Connection =
  sqlight.Connection

Represents errors that can occur during pool operations. Re-exported from pool_connection for convenience.

pub type DbError =
  pool_connection.DbError

A SQLite connection pool. Manages reusable database connections and handles checkout/checkin automatically. Created with start_pool and should be stopped with stop_pool when done.

pub opaque type Pool

Pool operations returned from FFI. Contains closures that capture the internal pool handle, providing checkout and stop functionality without exposing Erlang internals.

pub type PoolOps {
  PoolOps(
    checkout: fn() -> Result(
      #(sqlight.Connection, fn() -> Nil),
      String,
    ),
    stop: fn() -> Nil,
  )
}

Constructors

  • PoolOps(
      checkout: fn() -> Result(
        #(sqlight.Connection, fn() -> Nil),
        String,
      ),
      stop: fn() -> Nil,
    )

Values

pub fn get_connection(
  pool: Pool,
  f: fn(sqlight.Connection) -> a,
) -> a

Executes a function with a connection from the pool. The connection is automatically checked out before the function runs and returned to the pool when it completes.

pub fn start_pool(
  config: pool_connection.Config,
) -> Result(Pool, pool_connection.DbError)

Creates a new connection pool from the given configuration. The pool manages a set of reusable database connections and handles checkout/checkin automatically.

pub fn stop_pool(pool: Pool) -> Nil

Stops a connection pool and closes all connections. Should be called when the pool is no longer needed to free resources. Any connections still in use will be closed.

Search Document