File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22vendor /
33composer.lock
44runtime /*
5- config /constants.php
6- config /redis.php
7- config /secrets.php
8- config /server.php
5+ config /* .php
96test.php
Original file line number Diff line number Diff line change 1- # delay-queue
1+ # delay-server-single
22基于 Redis 实现的延时队列,只提供简单的延时能力,不负责业务相关队列,需要在创建队列时提供业务队列的连接信息,消息到期时自动将消息移动到业务队列。
33
44## 依赖
@@ -15,7 +15,7 @@ $ composer create-project --prefer-dist ruesin/delay-server-single
1515
1616## 配置
1717拷贝` ./config/samples/*.php ` 到` ./config/ ` ,并按需修改:
18- - ` constants .php` 常量定义
18+ - ` queue .php` 队列定义
1919- ` redis.php ` Redis服务器配置
2020- ` secrets.php ` 验证签名的密钥对
2121- ` server.php ` 服务启动的配置文件,参考[ swover] ( https://github.com/ruesin/swover )
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ public function __construct($request)
2727 * 创建队列
2828 *
2929 * @return string
30- * @throws \Exception
3130 */
3231 public function createQueue ()
3332 {
@@ -56,7 +55,6 @@ public function createQueue()
5655 /**
5756 * 删除队列
5857 * @return bool
59- * @throws \Exception
6058 */
6159 public function dropQueue ()
6260 {
@@ -71,7 +69,6 @@ public function dropQueue()
7169 /**
7270 * 发送消息
7371 * @return bool|string
74- * @throws \Exception
7572 */
7673 public function addMessage ()
7774 {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11<?php
22namespace App \Utils ;
33
4+ use Swover \Utils \Config ;
5+
46class Queue
57{
68 public static function queueListName ()
79 {
8- return QUEUE_LIST ;
10+ return Config:: get ( ' queue.list_name ' ) ;
911 }
1012
1113 public static function queueInfoName ()
1214 {
13- return QUEUE_INFO ;
15+ return Config:: get ( ' queue.info_name ' ) ;
1416 }
1517
1618 public static function delayName ($ queue_name )
1719 {
18- return $ queue_name .DELAY_SUFFIX ;
20+ return $ queue_name .Config:: get ( ' queue.delay_suffix ' ) ;
1921 }
2022}
Original file line number Diff line number Diff line change 11<?php
2+
23namespace App \Utils ;
34
45/**
@@ -59,7 +60,7 @@ public static function instance($config = [])
5960 public static function close ($ config = [])
6061 {
6162 $ config = self ::getConfig ($ config );
62- $ name = self ::configToName ($ config );
63+ $ name = self ::configToName ($ config );
6364
6465 if (isset (self ::$ _instance [$ name ])) {
6566 self ::$ _instance [$ name ]->quit ();
@@ -71,10 +72,10 @@ public static function close($config = [])
7172
7273 private static function getConfig ($ config )
7374 {
74- if (!empty ($ config )) {
75+ if (!empty ($ config )) {
7576 return $ config ;
7677 }
77- return Config::get ('redis ' );
78+ return \ Swover \ Utils \ Config::get ('redis ' );
7879 }
7980
8081 private static function configToName ($ config )
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public static function verify($request)
4040
4141 private static function secret ($ secretId )
4242 {
43- $ secrets = Config::get ('secrets ' );
43+ $ secrets = \ Swover \ Utils \ Config::get ('secrets ' );
4444 return isset ($ secrets [$ secretId ]) ? $ secrets [$ secretId ] : false ;
4545 }
4646}
Original file line number Diff line number Diff line change 1+ <?php
2+ (function () {
3+ \Swover \Utils \Config::loadPath (ROOT_DIR .'/config/ ' );
4+ })();
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1111 }
1212 ],
1313 "require" : {
14- "ruesin/swover" : " ^1.0 " ,
14+ "ruesin/swover" : " ^1.1 " ,
1515 "predis/predis" : " 1.1.1" ,
1616 "php" : " >=7.0" ,
1717 "ext-json" : " *"
1818 },
1919 "autoload" : {
2020 "psr-4" : {
2121 "App\\ " : " app/"
22- }
22+ },
23+ "files" : [
24+ " common/helpers.php"
25+ ]
2326 },
2427 "prefer-stable" : true ,
2528 "scripts" : {
You can’t perform that action at this time.
0 commit comments