Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
simple_pg_pool
Fork of deadpool-postgres for deeper integration into the simple_pg project.
Primary Goals:
- Deeply integrate with a SQL query builder.
- Unify client types so generic client isn't needed. Replaced by
impl Deref<Conn>. - Provided methods for fast & parallel unit testing via schema universes.
- Optimize performance for our use cases.
- Reduce incremental compile times via reducing monomorphization.
Features
| Feature | Description | Extra dependencies | Default |
|---|---|---|---|
rt_tokio_1 |
Enable support for tokio crate | deadpool/rt_tokio_1 |
yes |
rt_async-std_1 |
Enable support for async-std crate | deadpool/rt_async-std_1 |
no |
serde |
Enable support for serde crate | deadpool/serde, serde/derive |
no |
Important: async-std support is currently limited to the
async-std specific timeout function. You still need to enable
the tokio1 feature of async-std in order to use this crate
with async-std.
Example
The following example assumes a PostgreSQL reachable via an unix domain
socket and peer auth enabled for the local user in
pg_hba.conf.
If you're running Windows you probably want to specify the host, user
and password in the connection config or use an alternative
authentication method.
use ;
use NoTls;
async
Example with config and dotenv crate
# .env
PG__DBNAME=deadpool
use ;
use dotenv;
# use serde_1 as serde;
use NoTls;
#
async
Note: The code above uses the crate name config_crate because of the
config feature and both features and dependencies share the same namespace.
In your own code you will probably want to use ::config::ConfigError and
::config::Config instead.
Example using an existing simple_pg_client::Config object
use env;
use ;
use NoTls;
async
FAQ
-
The database is unreachable. Why does the pool creation not fail?
Deadpool has identical startup and runtime behaviour and therefore the pool creation will never fail.
If you want your application to crash on startup if no database connection can be established just call
pool.get().awaitright after creating the pool. -
Why are connections retrieved from the pool sometimes unuseable?
In
deadpool-postgres 0.5.5a new recycling method was implemented which is the default since0.8. With that recycling method the manager no longer performs a test query prior returning the connection but relies solely onsimple_pg_client::Client::is_closedinstead. Under some rare circumstances (e.g. unreliable networks) this can lead tosimple_pg_clientnot noticing a disconnect and reporting the connection as useable.The old and slightly slower recycling method can be enabled by setting
ManagerConfig::recycling_methodtoRecyclingMethod::Verifiedor when using theconfigcrate by settingPG__MANAGER__RECYCLING_METHOD=Verified. -
How can I enable features of the
tokio-postgrescrate?Make sure that you depend on the same version of
tokio-postgresasdeadpool-postgresdoes and enable the needed features in your ownCrate.tomlfile:[] = { = "0.9" } = { = "0.7", = ["with-uuid-0_8"] }Important: The version numbers of
deadpool-postgresandtokio-postgresdo not necessarily match. If they do it is just a coincidence that both crates have the same MAJOR and MINOR version number.deadpool-postgres tokio-postgres 0.7 – 0.12 0.7 0.6 0.6 0.4 – 0.5 0.5 0.2 – 0.3 0.5.0-alpha -
How can I clear the statement cache?
You can call
pool.manager().statement_cache.clear()to clear all statement caches orpool.manager().statement_cache.remove()to remove a single statement from all caches.Important: The
ClientWrapperalso provides astatement_cachefield which hasclear()andremove()methods which only affect a single client.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.