{"id":19638020,"url":"https://github.com/simon28082/connection-pool","last_synced_at":"2026-06-24T02:32:11.624Z","repository":{"id":56958813,"uuid":"150827328","full_name":"simon28082/connection-pool","owner":"simon28082","description":"connection pool","archived":false,"fork":false,"pushed_at":"2020-02-21T03:08:32.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-06T01:55:28.217Z","etag":null,"topics":["connection-pool","pool"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/simon28082.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}},"created_at":"2018-09-29T05:15:35.000Z","updated_at":"2020-02-21T03:08:34.000Z","dependencies_parsed_at":"2022-08-21T09:50:26.730Z","dependency_job_id":null,"html_url":"https://github.com/simon28082/connection-pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simon28082/connection-pool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simon28082%2Fconnection-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simon28082%2Fconnection-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simon28082%2Fconnection-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simon28082%2Fconnection-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simon28082","download_url":"https://codeload.github.com/simon28082/connection-pool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simon28082%2Fconnection-pool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34714992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["connection-pool","pool"],"created_at":"2024-11-11T12:37:24.792Z","updated_at":"2026-06-24T02:32:11.608Z","avatar_url":"https://github.com/simon28082.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 远程调用的统一客户端\n\n## 使用方法\n\n### 加载引入\n\n在`config/app.php`中增加\n```\n'providers' =\u003e [\n    CrCms\\Foundation\\ConnectionPool\\PoolServiceProvider::class,\n]\n```\n\n### 增加配置\n\n在`config/pool.php`的connections中增加如下测试配置\n```\n'client' =\u003e [\n    'max_idle_number' =\u003e 50,//最大空闲数\n    'min_idle_number' =\u003e 15,//最小空闲数\n    'max_connection_number' =\u003e 20,//最大连接数\n    'max_connection_time' =\u003e 3,//最大连接时间(s)\n],\n```\n\n### 调用方法\n\n#### ConnectionFactoryContract的实现\n目前已在`Client`模块中实现了`Client`的工厂方法,`Redis`,`Mysql`等连接池使用，请参考`Client`模块工厂\n\n```\n/* @var ConnectionManager $manager */\n$manager = $this-\u003eapp-\u003emake('pool.manager');\n\n$factory = $this-\u003eapp-\u003emake('client.factory');\n\n//获取当前连接  client:客户端连接池配置\n$connection = $manager-\u003econnection($factory, 'client');\n//发送请求\n$connection-\u003erequest('baidu.com',[]);\n//获取当前的连接资源的响应\ndump(get_class($connection-\u003egetResponse()));\n//获取资源响应内容\ndump($connection-\u003egetContent());\n//资源回收\n$manager-\u003eclose($connection);\n```\n\n### 动态化配置\n\n连接池也支持运行动态化加载配置，如下示例：\n```\n/* @var ConnectionManager $manager */\n$manager = $this-\u003eapp-\u003emake('pool.manager');\n\n$factory = $this-\u003eapp-\u003emake('client.factory');\n\n//获取当前连接  client:客户端连接池配置\n$connection = $manager-\u003econnection($factory, 'custom');\n//发送请求\n$connection-\u003erequest('baidu.com',[]);\n//获取当前的连接资源的响应\ndump(get_class($connection-\u003egetResponse()));\n//获取资源响应内容\ndump($connection-\u003egetContent());\n//资源回收\n$manager-\u003eclose($connection);\n```\n\n当连接池使用动态自定义连接名称时，则系统会使用默认的连接参数，如：\n\n```\n$connection = $manager-\u003econnection($factory, 'custom');\n```\n\n如果传入数组配置，则会优先以动态配置覆盖原默认配置\n\n```\n$connection = $manager-\u003econnection($factory, [\n    'name' =\u003e 'custom',\n    'max_idle_number' =\u003e 50,//最大空闲数\n    'min_idle_number' =\u003e 15,//最小空闲数\n    'max_connection_number' =\u003e 20,//最大连接数\n    'max_connection_time' =\u003e 3,//最大连接时间(s)\n]);\n```\n\n### 支持的类型\n- Client 客户端\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimon28082%2Fconnection-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimon28082%2Fconnection-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimon28082%2Fconnection-pool/lists"}