Skip to content

PostgreSQL connection pool library with support for re-establishing of lost connection

License

Notifications You must be signed in to change notification settings

manifest/postgresql-connection-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL connection pool

PostgreSQL connection pool library with support for re-establishing of lost connection.

Build Status

How To Use

To build and start playing with the library, execute following commands in the shell:

make app shell

Here is a minimal example of using the PostgreSQL connection pool library.

%% Creating a pool and adding it to the supervision tree.
Pool =
    #{name => default,
      size => 5,
      proc =>
        #{connection =>
            #{host => "localhost",
              username => "johndoe",
              database => "example"}}},
ChildSpec = pgsqlc_pool:child_spec(Pool),
supervisor:start_child(whereis(pgsqlc_pool_sup), ChildSpec).

%% Getting a connection and locking it to the current process.
%% If process dies, connection will be released.
Pid = pgsqlc_pool:lock(default),
%% Executing a query.
Ref = pgsqlc:query(Pid, "select 1;"),
%% Awaiting result.
pgsqlc:await(Pid, Ref),
%% Releasing the connection.
pgsqlc_pool:unlock(default, Pid).

License

The source code is provided under the terms of the MIT license.

About

PostgreSQL connection pool library with support for re-establishing of lost connection

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published