postgleam/pool

Types

Pool message type

pub type PoolMessage {
  Execute(
    fun: fn(
      connection.ConnectionState,
      dict.Dict(Int, codec.Codec),
      config.Config,
    ) -> #(
      Result(connection.ExtendedQueryResult, error.Error),
      connection.ConnectionState,
    ),
    reply: process.Subject(
      Result(connection.ExtendedQueryResult, error.Error),
    ),
  )
  SimpleExecute(
    fun: fn(connection.ConnectionState, config.Config) -> #(
      Result(List(connection.SimpleQueryResult), error.Error),
      connection.ConnectionState,
    ),
    reply: process.Subject(
      Result(List(connection.SimpleQueryResult), error.Error),
    ),
  )
  Shutdown(reply: process.Subject(Nil))
}

Constructors

Result from a decoded pool query.

pub type PoolResponse(a) {
  PoolResponse(rows: List(a), count: Int, tag: String)
}

Constructors

  • PoolResponse(rows: List(a), count: Int, tag: String)

Values

pub fn query(
  pool: process.Subject(PoolMessage),
  sql: String,
  params: List(option.Option(value.Value)),
  timeout: Int,
) -> Result(connection.ExtendedQueryResult, error.Error)

Execute a parameterized query through the pool

pub fn query_with(
  pool: process.Subject(PoolMessage),
  sql: String,
  params: List(option.Option(value.Value)),
  decoder: decode.RowDecoder(a),
  timeout: Int,
) -> Result(PoolResponse(a), error.Error)

Execute a parameterized query through the pool and decode rows.

pub fn shutdown(
  pool: process.Subject(PoolMessage),
  timeout: Int,
) -> Nil

Shut down the pool, disconnecting all connections

pub fn simple_query(
  pool: process.Subject(PoolMessage),
  sql: String,
  timeout: Int,
) -> Result(List(connection.SimpleQueryResult), error.Error)

Execute a simple query through the pool

pub fn start(
  config: config.Config,
  size: Int,
) -> Result(actor.Started(process.Subject(PoolMessage)), String)

Start a connection pool with the given config and size

Search Document