{"id":15354021,"url":"https://github.com/riron/swim","last_synced_at":"2026-02-21T03:01:09.475Z","repository":{"id":163404264,"uuid":"638655432","full_name":"Riron/swim","owner":"Riron","description":"A generic connection pool for Rust","archived":false,"fork":false,"pushed_at":"2023-05-11T07:50:05.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T22:15:52.281Z","etag":null,"topics":["async-await","connection-pool","database","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Riron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-05-09T20:19:35.000Z","updated_at":"2023-07-17T09:52:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9ac232d-2e34-4917-92b3-ffd87865273b","html_url":"https://github.com/Riron/swim","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"a52511ff38ef8fa558d47a5f68561cc6091b3468"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riron%2Fswim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riron%2Fswim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riron%2Fswim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Riron%2Fswim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Riron","download_url":"https://codeload.github.com/Riron/swim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245908445,"owners_count":20692107,"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":["async-await","connection-pool","database","rust","rust-lang"],"created_at":"2024-10-01T12:16:44.665Z","updated_at":"2025-10-20T02:37:33.734Z","avatar_url":"https://github.com/Riron.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swim\n\nA generic connection pool with [Tokio](https://tokio.rs/) support.\n\nInspired by [a Mobc rewrite that never happened](https://github.com/importcjj/mobc/pull/60#issuecomment-879616110).\n\nThis connection pool is **lock free** and uses a **single-thread event loop** instead. It seems to have a much better performance.\n\n# Example\n\n```rust\nuse swim::{Pool, PoolConfig};\n\n#[tokio::main]\nasync fn main() {\n    let manager = FooConnectionManager::new(\"foo://localhost:0000\"); // Imaginary \"foo\" DB.\n    let pool = Pool::new(manager, PoolConfig::default().max_open(50));\n\n    for i in 0..20 {\n        let pool = pool.clone();\n        tokio::spawn(async move {\n            let client = pool.get().await.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# Config\n\nThe config must be passed to the pool upon creation. It comes with default params that can be changed through a fluent API.\n```rust\nlet config = PoolConfig::default()\n  .max_open(20)\n  .cleanup_rate(Duration::from_secs(5 * 60));\n```\n\n|Param|Type|Description|Default|\n|-----|----|-----------|-------|\n|max_open|`u16`|Maximum number of connections managed by the pool. Defaults to 10.\n|max_idle|`Option\u003cu16\u003e`|Maximum idle connection count maintained by the pool.|None, meaning reuse forever\n|max_lifetime|`Option\u003cDuration\u003e`|Maximum lifetime of connections in the pool. |None, meaning reuse forever\n|idle_timeout|`Option\u003cDuration\u003e`|Maximum lifetime of idle connections in the pool.|5min\n|cleanup_rate|`Duration`|Rate at which a connection cleanup is scheduled. |60sec\n|test_on_check_out|`bool`|Check the connection before returning it to the client.|false\n|get_timeout|`Duration`|Maximum time to wait for a connection to become available before returning an error.|30sec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friron%2Fswim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friron%2Fswim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friron%2Fswim/lists"}