Progress Description (20220820)
The imi-etcd released this time is contributed by the community. The author is @青星Chris , who has officially become a member of the imi development team!
imi-etcd implements the function of configuration center. Since imi-config-center abstracts the interface, it is very similar to imi-nacos in use.
Yurun introduced the next development plan to everyone at the imi's fourth anniversary live event.
Among them, it is clearly pointed out that the imi development team should vigorously develop the microservice ecosystem and contribute to PHP microservices.
The first step is to configure the center for imi access.
At present, the abstraction of the imi-config-center configuration center component has been implemented.
Implemented and released v2.1.0-beta
version:
All have been written and passed automated integration tests, and test cases are the basic requirements of the imi development team for imi-related development
Use of imi-etcd
Install
composer require imiphp/imi-etcd:~2.1.0
Instructions for use
configure
@app.beans
:
[
'ConfigCenter' => [
// 'mode' => \Imi\ConfigCenter\Enum\Mode::WORKER, // 工作进程模式
'mode' => \Imi\ConfigCenter\Enum\Mode::PROCESS, // 进程模式
'configs' => [
'etcd' => [
'driver' => \Imi\Etcd\Config\EtcdConfigDriver::class,
// 客户端连接配置
'client' => [
'scheme' => env('IMI_ETCD_SCHEME', 'http'), // http or https
'host' => env('IMI_ETCD_HOST', '127.0.0.1'), // 主机名
'port' => env('IMI_ETCD_PORT', 2379), // 端口号
'timeout' => env('IMI_ETCD_TIMEOUT', 6000), // 网络请求超时时间,单位:毫秒
'ssl' => env('IMI_ETCD_SSL', false), // 是否使用 ssl(https) 请求
'version' => env('IMI_ETCD_VERSION', 'v3'), /**
* v3 v3alpha v3beta v2
* etcd v3.2以及之前版本只使用[CLIENT-URL]/v3alpha/*。
* etcd v3.3使用[CLIENT-URL]/v3beta/*保持[CLIENT-URL]/v3alpha/*使用。
* etcd v3.4使用[CLIENT-URL]/v3/*保持[CLIENT-URL]/v3beta/*使用。
* [CLIENT-URL]/v3alpha/*被抛弃使用。
* etcd v3.5以及最新版本只使用[CLIENT-URL]/v3/*。
* [CLIENT-URL]/v3beta/*被抛弃使用。
*/
'pretty' => env('IMI_ETCD_PRETTY', true),
'sslCert' => '',
'sslKey' => ''
]
],
],
],
]
get configuration
\Imi\Config::get('etcd'); // 对应 imi-etcd-key1
write configuration
/** @var \Imi\ConfigCenter\ConfigCenter $configCenter */
$configCenter = App::getBean('ConfigCenter');
$name = 'imi-etcd-key1';
$value = json_encode(['imi' => 'niubi']);
$options = [];
$configCenter->getDriver('etcd')->push($name, $value);
$configCenter->getDriver('etcd')->push($name, $value, $options);
Benefits of Configuration Center
We usually put some configuration into a special configuration file, which is usually distributed and deployed with the code.
When you need to modify the configuration, you need to go through the release process again, which is very cumbersome and inconvenient.
At this time, the role of the configuration center is reflected.
We take the configuration from the configuration center instead of writing it in the project, and can flexibly realize the configuration release without interrupting the service.
imi configuration center component design
monitor mode
Worker Process Mode
Each process monitors itself, which is suitable for the Swoole environment.
Process mode
Monitored by a dedicated process and notified to other processes. Applicable to Swoole, Workerman environment.
Less pressure on the configuration center.
The php-fpm mode is special, it is the file caching logic. It takes more than a certain time to request the configuration center to obtain data, and the real-time performance will have a certain impact.
Monitoring method
Client polling
The client regularly requests the configuration center, which puts a lot of pressure on the configuration center server, but it is the most common.
Server push (long polling)
If the configuration center supports server push (long polling), it is recommended to use this method to reduce the pressure on the configuration center server.
near-term development plan
- Continue to maintain and iterate the core functions of imi remain unchanged for thousands of years
- Develop more specific implementations of imi configuration centers (Apollo, Zookeeper, Consul)
If you are interested in open source and imi projects, you may wish to develop together.
Simply develop an approved imi component or an imi-based open source project to become a member of the imi development team.
Introduction to imi
imi is a distributed PHP development framework that supports long-connection microservices. It can run in various container environments such as PHP-FPM, Swoole, Workerman, and RoadRunner.
imi has rich functional components, and the v2.1 version has built-in 2 solutions for distributed long-term connection services.
The imi framework is now running stably in: cultural travel e-commerce platform, IoT charging cloud platform, parking cloud platform, payment microservice, SMS microservice, wallet microservice, card game server, data migration service (Hupu), etc. in the project.
The first version of imi was published on June 21, 2018
project address
- Github: https://github.com/imiphp/imi
- Gitee: https://gitee.com/yurunsoft/IMI
- Official website: https://www.imiphp.com/
- Documentation: https://doc.imiphp.com/v2.1/
Honors received
- Recommended by InfoQ: https://mp.weixin.qq.com/s/oBbPRE0fvJR7aKOzJM_wxQ
- Code Cloud GVP Project: https://gitee.com/yurunsoft/IMI
Development team members
Yurun (Zhang Runyu), born on Arbor Day in 1994, is a native of Wuxi. Swoole development team member , php-src kernel contributor , TDengine contributor , top 100 Chinese open source code list in 2021 .
Open source projects include but are not limited to: imi, PaySDK, YurunHttp, Guzzle-Swoole, YurunOAuthLogin, ChineseUtil, etc.
Github: https://github.com/Yurunsoft
NHZEX, main contributions: code optimization, bug fixes, test optimization, PHP 8.1 compatibility
Github: https://github.com/NHZEX
Fengchen, 1993, Leo, native of Xuancheng. Member of the imi framework development team, open source author.
Open source projects include but are not limited to: fcup, mjs, university font icon library, fcphp, fcblog, etc. Main contributions: early users of imi, authors of imi 1.0 and 2.0 official website pages
Github: https://github.com/lovefc
Arno Eno, born in 1999, a native of Chengdu, full-stack programmer (main backend), medical student (undergraduate nursing major), master candidate of World War II.
Common programming languages PHP, NodeJs, etc., member of the imi framework development team.
A nurse who is keen to create the world with code. He only loves PHP. During college, he led the development of more than 20 WEB projects mainly using PHP as the backend. .
Major contributions: documentation, bug fixes
Github: https://github.com/Gumo666
Qingxuan Chris, 1996, Cantonese, PHP trainee for n and a half years, likes to sing\dance\RAP\PHP, member of the imi framework development team
Likes to participate in open source power generation with love, member of the imi framework development team, and contributor to the EasySwoole community
Main contribution: imi-etcd author
Github: https://github.com/ChrisLeeAreemm
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。