{"id":13438938,"url":"https://github.com/sfackler/r2d2","last_synced_at":"2025-05-13T23:08:05.407Z","repository":{"id":19387783,"uuid":"22628837","full_name":"sfackler/r2d2","owner":"sfackler","description":"A generic connection pool for Rust","archived":false,"fork":false,"pushed_at":"2024-10-10T01:01:52.000Z","size":316,"stargazers_count":1561,"open_issues_count":24,"forks_count":83,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-01T20:18:48.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sfackler.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-05T03:25:09.000Z","updated_at":"2025-03-30T00:41:21.000Z","dependencies_parsed_at":"2022-07-09T17:00:16.890Z","dependency_job_id":"4a4256a1-6d22-42f9-85fb-0c57bf6283d5","html_url":"https://github.com/sfackler/r2d2","commit_stats":{"total_commits":320,"total_committers":36,"mean_commits":8.88888888888889,"dds":"0.15000000000000002","last_synced_commit":"c1b0d9f976e12e97f92554063a7c6bd295eee471"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfackler%2Fr2d2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfackler%2Fr2d2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfackler%2Fr2d2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfackler%2Fr2d2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfackler","download_url":"https://codeload.github.com/sfackler/r2d2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247927405,"owners_count":21019525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:09.798Z","updated_at":"2025-04-08T21:13:24.803Z","avatar_url":"https://github.com/sfackler.png","language":"Rust","readme":"# r2d2\n[![CircleCI](https://circleci.com/gh/sfackler/r2d2.svg?style=shield)](https://circleci.com/gh/sfackler/r2d2)\n\nA generic connection pool for Rust.\n\n[Documentation](https://docs.rs/r2d2)\n\nOpening a new database connection every time one is needed is both inefficient\nand can lead to resource exhaustion under high traffic conditions. A connection\npool maintains a set of open connections to a database, handing them out for\nrepeated use.\n\nr2d2 is agnostic to the connection type it is managing. Implementors of the\n`ManageConnection` trait provide the database-specific logic to create and\ncheck the health of connections.\n\nA (possibly not exhaustive) list of adaptors for different backends:\n\nBackend                                                                | Adaptor Crate\n---------------------------------------------------------------------- | -------------\n[rust-postgres](https://github.com/sfackler/rust-postgres)             | [r2d2-postgres](https://github.com/sfackler/r2d2-postgres)\n[redis-rs](https://github.com/mitsuhiko/redis-rs)                      | use `r2d2` feature of [redis-rs](https://github.com/mitsuhiko/redis-rs)\n[rust-memcache](https://github.com/aisk/rust-memcache)                 | [r2d2-memcache](https://github.com/megumish/r2d2-memcache)\n[rust-mysql-simple](https://github.com/blackbeam/rust-mysql-simple)    | [r2d2-mysql](https://github.com/outersky/r2d2-mysql)\n[rusqlite](https://github.com/jgallagher/rusqlite)                     | [r2d2-sqlite](https://github.com/ivanceras/r2d2-sqlite)\n[rsfbclient](https://github.com/fernandobatels/rsfbclient)                     | [r2d2-firebird](https://crates.io/crates/r2d2_firebird/)\n[rusted-cypher](https://github.com/livioribeiro/rusted-cypher)         | [r2d2-cypher](https://github.com/flosse/r2d2-cypher)\n[diesel](https://github.com/sgrif/diesel)                              | [diesel::r2d2](https://github.com/diesel-rs/diesel/blob/master/diesel/src/r2d2.rs) ([docs](https://docs.rs/diesel/latest/diesel/r2d2/index.html))\n[couchdb](https://github.com/chill-rs/chill)                           | [r2d2-couchdb](https://github.com/scorphus/r2d2-couchdb)\n[mongodb (archived)](https://github.com/mongodb-labs/mongo-rust-driver-prototype)\u003cbr\u003euse official [mongodb](https://github.com/mongodb/mongo-rust-driver) driver instead                             | [r2d2-mongodb](https://gitlab.com/petoknm/r2d2-mongodb)\u003cbr\u003e(deprecated: official driver handles pooling internally)\n[odbc](https://github.com/Koka/odbc-rs)                                | [r2d2-odbc](https://github.com/Koka/r2d2-odbc)\n[jfs](https://github.com/flosse/rust-json-file-store)                  | [r2d2-jfs](https://github.com/flosse/r2d2-jfs)\n[oracle](https://github.com/kubo/rust-oracle)                          | [r2d2-oracle](https://github.com/rursprung/r2d2-oracle)\n[ldap3](https://github.com/inejge/ldap3)                               | [r2d2-ldap](https://github.com/c0dearm/r2d2-ldap)\n[duckdb-rs](https://github.com/wangfenjin/duckdb-rs)                   | use `r2d2` feature of [duckdb-rs](https://github.com/wangfenjin/duckdb-rs)\n\n# Example\n\nUsing an imaginary \"foodb\" database.\n\n```rust\nuse std::thread;\n\nextern crate r2d2;\nextern crate r2d2_foodb;\n\nfn main() {\n    let manager = r2d2_foodb::FooConnectionManager::new(\"localhost:1234\");\n    let pool = r2d2::Pool::builder()\n        .max_size(15)\n        .build(manager)\n        .unwrap();\n\n    for _ in 0..20 {\n        let pool = pool.clone();\n        thread::spawn(move || {\n            let conn = pool.get().unwrap();\n            // use the connection\n            // it will be returned to the pool when it falls out of scope.\n        })\n    }\n}\n```\n\n## License\n\nLicensed under either of\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you shall be dual licensed as above, without any\nadditional terms or conditions.\n","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库"],"sub_categories":["Database","数据库 Database","数据库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfackler%2Fr2d2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfackler%2Fr2d2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfackler%2Fr2d2/lists"}