Skip to content

Commit f365d57

Browse files
committed
Merge branch 'dev'
# Conflicts: # tests/phpunit
2 parents 90a3fcd + fe2f1f3 commit f365d57

File tree

20 files changed

+332
-325
lines changed

20 files changed

+332
-325
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- 消费超时机制
1919
- 失败/超时消息重新消费
2020

21+
> 本仓库仅用于浏览,不接受 issue 和 Pull Requests,请前往:<https://github.com/Yurunsoft/imi>
22+
2123
## Composer
2224

2325
本项目可以使用composer安装,遵循psr-4自动加载规则,在你的 `composer.json` 中加入下面的内容:
@@ -266,6 +268,6 @@ QQ群:17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png "
266268

267269
## 捐赠
268270

269-
<img src="https://raw.githubusercontent.com/imiphp/imi-queue/master/res/pay.png"/>
271+
<img src="https://cdn.jsdelivr.net/gh/Yurunsoft/IMI@dev/res/pay.png"/>
270272

271273
开源不求盈利,多少都是心意,生活不易,随缘随缘……

composer.json

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,28 @@
33
"type": "library",
44
"license": "MIT",
55
"description": "imi 框架的队列组件,使用 Redis 作为持久化",
6-
"require": {
7-
8-
},
6+
"require": {},
97
"require-dev": {
10-
"yurunsoft/imi": "dev-dev",
11-
"phpunit/phpunit": ">=7",
12-
"yurunsoft/ide-helper": "~1.0"
8+
"yurunsoft/ide-helper": "~1.0",
9+
"swoole/ide-helper": "^4.6"
1310
},
1411
"autoload": {
15-
"psr-4" : {
16-
"Imi\\Queue\\" : "src/"
12+
"psr-4": {
13+
"Imi\\Queue\\": "src/"
1714
}
1815
},
1916
"autoload-dev": {
20-
"psr-4" : {
21-
"ImiApp\\" : "example/",
22-
"Imi\\Queue\\Test\\" : "tests/"
17+
"psr-4": {
18+
"QueueApp\\": "example/",
19+
"Imi\\Queue\\Test\\": "tests/"
2320
}
2421
},
25-
"scripts": {
26-
"test": "./vendor/bin/phpunit -c ./tests/phpunit.xml",
27-
"install-test": "php --ri swoole && composer install composer test"
28-
},
22+
"scripts": {},
2923
"extra": {
3024
"ide-helper": {
3125
"list": [
32-
"swoole",
3326
"redis"
3427
]
3528
}
3629
}
37-
}
30+
}

example/HttpServer/Main.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace ImiApp\HttpServer;
2+
3+
namespace QueueApp\HttpServer;
34

45
use Imi\Main\BaseMain;
56

@@ -9,5 +10,4 @@ public function __init()
910
{
1011
// 可以做一些初始化操作
1112
}
12-
13-
}
13+
}

example/Main.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace ImiApp;
2+
3+
namespace QueueApp;
34

45
use Imi\Main\AppBaseMain;
56

@@ -8,7 +9,5 @@ class Main extends AppBaseMain
89
public function __init()
910
{
1011
// 这里可以做一些初始化操作,如果需要的话
11-
1212
}
13-
14-
}
13+
}

example/config/beans.php

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,41 @@
33
use Imi\Log\LogLevel;
44

55
$rootPath = dirname(__DIR__) . '/';
6+
67
return [
7-
'hotUpdate' => [
8+
'hotUpdate' => [
89
// 'status' => false, // 关闭热更新去除注释,不设置即为开启,建议生产环境关闭
910

1011
// --- 文件修改时间监控 ---
1112
// 'monitorClass' => \Imi\HotUpdate\Monitor\FileMTime::class,
12-
'timespan' => 1, // 检测时间间隔,单位:秒
13+
'timespan' => 1, // 检测时间间隔,单位:秒
1314

1415
// --- Inotify 扩展监控 ---
1516
// 'monitorClass' => \Imi\HotUpdate\Monitor\Inotify::class,
1617
// 'timespan' => 1, // 检测时间间隔,单位:秒,使用扩展建议设为0性能更佳
1718

1819
// 'includePaths' => [], // 要包含的路径数组
19-
'excludePaths' => [
20+
'excludePaths' => [
2021
$rootPath . '.git',
2122
$rootPath . 'bin',
2223
$rootPath . 'logs',
2324
], // 要排除的路径数组,支持通配符*
2425
],
25-
'Logger' => [
26-
'exHandlers' => [
26+
'Logger' => [
27+
'exHandlers' => [
2728
// info 级别日志不输出trace
2829
[
29-
'class' => \Imi\Log\Handler\File::class,
30-
'options' => [
30+
'class' => \Imi\Log\Handler\File::class,
31+
'options' => [
3132
'levels' => [LogLevel::INFO],
3233
'fileName' => dirname(__DIR__) . '/.runtime/logs/{Y}-{m}-{d}.log',
33-
'format' => "{Y}-{m}-{d} {H}:{i}:{s} [{level}] {message}",
34+
'format' => '{Y}-{m}-{d} {H}:{i}:{s} [{level}] {message}',
3435
],
3536
],
3637
// 指定级别日志输出trace
3738
[
38-
'class' => \Imi\Log\Handler\File::class,
39-
'options' => [
39+
'class' => \Imi\Log\Handler\File::class,
40+
'options' => [
4041
'levels' => [
4142
LogLevel::ALERT,
4243
LogLevel::CRITICAL,
@@ -49,57 +50,57 @@
4950
'fileName' => dirname(__DIR__) . '/.runtime/logs/{Y}-{m}-{d}.log',
5051
'format' => "{Y}-{m}-{d} {H}:{i}:{s} [{level}] {message}\n{trace}",
5152
'traceFormat' => '#{index} {call} called at [{file}:{line}]',
52-
'traceMinimum' => true,
53+
'traceMinimum' => true,
5354
],
54-
]
55+
],
5556
],
5657
],
57-
'AutoRunProcessManager' => [
58-
'processes' => [
58+
'AutoRunProcessManager' => [
59+
'processes' => [
5960
// 加入队列消费进程,非必须,你也可以自己写进程消费
6061
'QueueConsumer',
6162
],
6263
],
63-
'imiQueue' => [
64+
'imiQueue' => [
6465
// 默认队列
65-
'default' => 'test1',
66+
'default' => 'test1',
6667
// 队列列表
67-
'list' => [
68+
'list' => [
6869
// 队列名称
69-
'test1' => [
70+
'test1' => [
7071
// 使用的队列驱动
71-
'driver' => 'RedisQueueDriver',
72+
'driver' => 'RedisQueueDriver',
7273
// 消费协程数量
73-
'co' => 1,
74+
'co' => 1,
7475
// 消费进程数量;可能会受进程分组影响,以同一组中配置的最多进程数量为准
75-
'process' => 1,
76+
'process' => 1,
7677
// 消费循环尝试 pop 的时间间隔,单位:秒
77-
'timespan' => 0.1,
78+
'timespan' => 0.1,
7879
// 进程分组名称
79-
'processGroup' => 'a',
80+
'processGroup' => 'a',
8081
// 自动消费
81-
'autoConsumer' => true,
82+
'autoConsumer' => true,
8283
// 消费者类
83-
'consumer' => 'AConsumer',
84+
'consumer' => 'AConsumer',
8485
// 驱动类所需要的参数数组
85-
'config' => [
86-
'poolName' => 'redis',
87-
'prefix' => 'imi:queue:test:',
88-
]
86+
'config' => [
87+
'poolName' => 'redis',
88+
'prefix' => 'imi:queue:test:',
89+
],
8990
],
90-
'test2' => [
91-
'driver' => 'RedisQueueDriver',
92-
'co' => 1,
93-
'process' => 1,
94-
'timespan' => 0.1,
95-
'processGroup' => 'b',
96-
'autoConsumer' => true,
97-
'consumer' => 'BConsumer',
98-
'config' => [
99-
'poolName' => 'redis',
100-
'prefix' => 'imi:queue:test:',
101-
]
91+
'test2' => [
92+
'driver' => 'RedisQueueDriver',
93+
'co' => 1,
94+
'process' => 1,
95+
'timespan' => 0.1,
96+
'processGroup' => 'b',
97+
'autoConsumer' => true,
98+
'consumer' => 'BConsumer',
99+
'config' => [
100+
'poolName' => 'redis',
101+
'prefix' => 'imi:queue:test:',
102+
],
102103
],
103104
],
104105
],
105-
];
106+
];

example/config/config.php

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@
44

55
return [
66
// 项目根命名空间
7-
'namespace' => 'ImiApp',
7+
'namespace' => 'QueueApp',
88

99
// 配置文件
10-
'configs' => [
11-
'beans' => __DIR__ . '/beans.php',
10+
'configs' => [
11+
'beans' => __DIR__ . '/beans.php',
1212
],
1313

1414
// 扫描目录
15-
'beanScan' => [
16-
'ImiApp\Consumer',
17-
'ImiApp\Listener',
15+
'beanScan' => [
16+
'QueueApp\Consumer',
17+
'QueueApp\Listener',
1818
],
1919

2020
// 组件命名空间
21-
'components' => [
22-
'Queue' => 'Imi\Queue',
21+
'components' => [
22+
'Queue' => 'Imi\Queue',
2323
],
2424

2525
// 主服务器配置
26-
'mainServer' => [
27-
'namespace' => 'ImiApp\HttpServer',
28-
'type' => Type::HTTP,
29-
'host' => '127.0.0.1',
30-
'port' => 8080,
31-
'configs' => [
32-
'worker_num' => 1,
26+
'mainServer' => [
27+
'namespace' => 'QueueApp\HttpServer',
28+
'type' => Type::HTTP,
29+
'host' => '127.0.0.1',
30+
'port' => 8080,
31+
'configs' => [
32+
'worker_num' => 1,
3333
],
3434
],
3535

3636
// 连接池配置
37-
'pools' => [
38-
'redis' => [
37+
'pools' => [
38+
'redis' => [
3939
'pool' => [
4040
// 同步池类名
41-
'syncClass' => \Imi\Redis\SyncRedisPool::class,
41+
'syncClass' => \Imi\Redis\SyncRedisPool::class,
4242
// 协程池类名
43-
'asyncClass' => \Imi\Redis\CoroutineRedisPool::class,
44-
'config' => [
43+
'asyncClass' => \Imi\Redis\CoroutineRedisPool::class,
44+
'config' => [
4545
// 池子中最多资源数
4646
'maxResources' => 10,
4747
// 池子中最少资源数
@@ -64,41 +64,40 @@
6464
],
6565
// 数组资源配置
6666
'resource' => [
67-
'host' => '127.0.0.1',
68-
'port' => 6379,
67+
'host' => imiGetEnv('REDIS_SERVER_HOST', '127.0.0.1'),
68+
'port' => 6379,
6969
// 是否自动序列化变量
70-
'serialize' => false,
70+
'serialize' => false,
7171
// 密码
72-
'password' => null,
72+
'password' => null,
7373
// 第几个库
74-
'db' => 0,
74+
'db' => 0,
7575
],
7676
// uri资源配置,以分号;分隔多个,参数使用query参数格式,特殊字符需要转码
7777
],
7878
],
7979

8080
// 数据库配置
81-
'db' => [
81+
'db' => [
8282
// 数默认连接池名
83-
'defaultPool' => 'maindb',
83+
'defaultPool' => 'maindb',
8484
],
8585

8686
// redis 配置
87-
'redis' => [
87+
'redis' => [
8888
// 数默认连接池名
89-
'defaultPool' => 'redis',
89+
'defaultPool' => 'redis',
9090
],
9191

9292
// 锁
93-
'lock' =>[
94-
'list' => [
95-
'redisConnectContextLock' => [
96-
'class' => 'RedisLock',
97-
'options' => [
98-
'poolName' => 'redis',
93+
'lock' => [
94+
'list' => [
95+
'redisConnectContextLock' => [
96+
'class' => 'RedisLock',
97+
'options' => [
98+
'poolName' => 'redis',
9999
],
100100
],
101101
],
102102
],
103-
104-
];
103+
];

0 commit comments

Comments
 (0)