{"id":19756818,"url":"https://github.com/imiphp/imi-etcd","last_synced_at":"2025-04-30T12:30:47.872Z","repository":{"id":50562547,"uuid":"519454162","full_name":"imiphp/imi-etcd","owner":"imiphp","description":"imi 框架 etcd 组件。imi etcd component.","archived":false,"fork":false,"pushed_at":"2022-08-19T09:05:18.000Z","size":79,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"2.1","last_synced_at":"2024-05-23T01:32:31.876Z","etag":null,"topics":["coroutine","etcd","php","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imiphp.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":"2022-07-30T07:52:22.000Z","updated_at":"2023-11-11T10:29:50.000Z","dependencies_parsed_at":"2022-08-12T21:40:50.187Z","dependency_job_id":null,"html_url":"https://github.com/imiphp/imi-etcd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-etcd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-etcd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-etcd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-etcd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imiphp","download_url":"https://codeload.github.com/imiphp/imi-etcd/tar.gz/refs/heads/2.1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224207897,"owners_count":17273674,"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":["coroutine","etcd","php","swoole"],"created_at":"2024-11-12T03:17:04.921Z","updated_at":"2024-11-12T03:17:05.530Z","avatar_url":"https://github.com/imiphp.png","language":"PHP","readme":"\n# imi-etcd\n\n[![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-etcd.svg)](https://packagist.org/packages/imiphp/imi-etcd)\n[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/)\n[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.8.0-brightgreen.svg)](https://github.com/swoole/swoole-src)\n[![imi License](https://img.shields.io/badge/license-MulanPSL%202.0-brightgreen.svg)](https://github.com/imiphp/imi-etcd/blob/2.1/LICENSE)\n\n## 介绍\n\n此项目是 imi 框架的 etcd 组件。\n\n\u003e 正在开发中，随时可能修改，请勿用于生产环境！\n\n**支持的功能：**\n\n* [x] 配置中心\n\n## 安装\n\n`composer require imiphp/imi-etcd:~2.1.0`\n\n## 使用说明\n\n### 配置\n\n`@app.beans`：\n\n```php\nuse function Imi\\env;\nuse Imi\\Util\\Imi;\n\n[\n    'ConfigCenter' =\u003e [\n        // 'mode'    =\u003e \\Imi\\ConfigCenter\\Enum\\Mode::WORKER, // 工作进程模式\n        'mode'    =\u003e \\Imi\\ConfigCenter\\Enum\\Mode::PROCESS, // 进程模式\n        'configs' =\u003e [\n            'etcd' =\u003e [\n                'driver'  =\u003e \\Imi\\Etcd\\Config\\EtcdConfigDriver::class,\n                // 客户端连接配置\n                'client'  =\u003e [\n                    'scheme'              =\u003e env('IMI_ETCD_SCHEME', 'http'), // http or https\n                    'host'                =\u003e env('IMI_ETCD_HOST', '127.0.0.1'), // 主机名\n                    'port'                =\u003e env('IMI_ETCD_PORT', 2379), // 端口号\n                    'timeout'             =\u003e env('IMI_ETCD_TIMEOUT', 6000), // 网络请求超时时间，单位：毫秒\n                    'ssl'                 =\u003e env('IMI_ETCD_SSL', false), // 是否使用 ssl(https) 请求\n                    'version'             =\u003e env('IMI_ETCD_VERSION', 'v3'), /**\n                     * v3 v3alpha v3beta v2\n                     * etcd v3.2以及之前版本只使用[CLIENT-URL]/v3alpha/*。\n                     * etcd v3.3使用[CLIENT-URL]/v3beta/*保持[CLIENT-URL]/v3alpha/*使用。\n                     * etcd v3.4使用[CLIENT-URL]/v3/*保持[CLIENT-URL]/v3beta/*使用。\n                     * [CLIENT-URL]/v3alpha/*被抛弃使用。\n                     * etcd v3.5以及最新版本只使用[CLIENT-URL]/v3/*。\n                     * [CLIENT-URL]/v3beta/*被抛弃使用。\n                     */\n                    'pretty'              =\u003e env('IMI_ETCD_PRETTY', true),\n                    'sslCert'             =\u003e '',\n                    'sslKey'              =\u003e ''\n                ],\n                // 监听器配置\n                'listener' =\u003e [\n                    'timeout'         =\u003e 30000, // 配置监听器长轮询超时时间，单位：毫秒\n                    'failedWaitTime'  =\u003e 3000, // 失败后等待重试时间，单位：毫秒\n                    'savePath'        =\u003e Imi::getRuntimePath('config-cache'), // 配置保存路径，默认为空不保存到文件。php-fpm 模式请一定要设置！\n                    'fileCacheTime'   =\u003e 30, // 文件缓存时间，默认为0时不受缓存影响，此配置只影响 pull 操作。php-fpm 模式请一定要设置为大于0的值！\n                    'pollingInterval' =\u003e 10000, // 客户端轮询间隔时间，单位：毫秒\n                ],\n                // 配置项\n                'configs' =\u003e [\n                    'etcd' =\u003e [\n                        'key'  =\u003e 'imi-etcd-key1',\n                    ],\n                ],\n            ],\n        ],\n    ],\n]\n```\n\n### 获取配置\n\n```php\n\\Imi\\Config::get('etcd'); // 对应 imi-etcd-key1\n```\n\n### 写入配置\n\n```php\n/** @var \\Imi\\ConfigCenter\\ConfigCenter $configCenter */\n$configCenter = App::getBean('ConfigCenter');\n$name = 'imi-etcd-key1';\n$value = json_encode(['imi' =\u003e 'niubi']);\n$options = [];\n$configCenter-\u003egetDriver('etcd')-\u003epush($name, $value);\n$configCenter-\u003egetDriver('etcd')-\u003epush($name, $value, $options);\n```\n\n## 免费技术支持\n\nQQ群：17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png \"点击加群\")](https://jq.qq.com/?_wv=1027\u0026k=5wXf4Zq)，如有问题会有人解答和修复。\n\n## 运行环境\n\n* [PHP](https://php.net/) \u003e= 7.4\n* [Composer](https://getcomposer.org/) \u003e= 2.0\n* [Swoole](https://www.swoole.com/) \u003e= 4.8.0\n* [imi](https://www.imiphp.com/) \u003e= 2.1\n\n## 版权信息\n\n`imi-etcd` 遵循 MulanPSL-2.0 开源协议发布，并提供免费使用。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-etcd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimiphp%2Fimi-etcd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-etcd/lists"}