abstract class CQL::ConnectionSource

Overview

Where a Schema borrows its connections and transactions from. The Schema keeps the per-fiber transaction pinning and the telemetry; a source only knows how to lend a connection and how to open a transaction on one.

DatabaseSource (crystal-db's pool) is the default. Postgres::EngineSource runs a schema on the native AsyncEngine's pool.

Direct Known Subclasses

Defined in:

connection_source.cr

Instance Method Summary

Instance Method Detail

def adapter : Adapter | Nil #

The adapter this source speaks, when it is bound to one (a Schema refuses a different one).


[View source]
abstract def close : Nil #

[View source]
def database_uri(uri : String) : String #

The URI a Schema reports (Schema#uri), which code such as SchemaDump opens through crystal-db.


[View source]
abstract def pool_stats : PoolStats #

[View source]
abstract def transaction(& : DB::Transaction -> _) #

Runs the block in a transaction on one connection: committed when the block returns, rolled back when it raises. DB::Rollback rolls back quietly and makes this return nil.


[View source]
abstract def using_connection(& : DB::Connection -> _) #

Lends one connection to the block and takes it back afterwards.


[View source]