mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 00:25:35 +08:00
Merge pull request #74 from zhamao-robot/fix-onsetup-attribute-exec
Fix OnSetup Attribute execution bug (release 2.7.3)
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
@@ -16,6 +17,7 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
* @Target("METHOD")
|
* @Target("METHOD")
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
|
||||||
class OnTick extends AnnotationBase
|
class OnTick extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Annotation\Swoole;
|
namespace ZM\Annotation\Swoole;
|
||||||
|
|
||||||
|
use Attribute;
|
||||||
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
||||||
use Doctrine\Common\Annotations\Annotation\Required;
|
use Doctrine\Common\Annotations\Annotation\Required;
|
||||||
use Doctrine\Common\Annotations\Annotation\Target;
|
use Doctrine\Common\Annotations\Annotation\Target;
|
||||||
@@ -15,6 +16,7 @@ use ZM\Annotation\AnnotationBase;
|
|||||||
* @NamedArgumentConstructor()
|
* @NamedArgumentConstructor()
|
||||||
* @Target("ALL")
|
* @Target("ALL")
|
||||||
*/
|
*/
|
||||||
|
#[Attribute(Attribute::TARGET_ALL)]
|
||||||
class SwooleHandler extends AnnotationBase
|
class SwooleHandler extends AnnotationBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use ZM\Exception\InitException;
|
|||||||
|
|
||||||
class ConsoleApplication extends Application
|
class ConsoleApplication extends Application
|
||||||
{
|
{
|
||||||
public const VERSION_ID = 451;
|
public const VERSION_ID = 453;
|
||||||
|
|
||||||
public const VERSION = '2.7.3';
|
public const VERSION = '2.7.3';
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace ZM\Http;
|
namespace ZM\Http;
|
||||||
|
|
||||||
|
use ZM\Annotation\Http\Middleware;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property Middleware $middleware
|
||||||
|
*/
|
||||||
interface MiddlewareInterface
|
interface MiddlewareInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\AnnotationReader;
|
use Doctrine\Common\Annotations\AnnotationReader;
|
||||||
|
use Koriym\Attributes\AttributeReader;
|
||||||
|
use Koriym\Attributes\DualReader;
|
||||||
use ZM\Annotation\Swoole\OnSetup;
|
use ZM\Annotation\Swoole\OnSetup;
|
||||||
use ZM\Annotation\Swoole\SwooleHandler;
|
use ZM\Annotation\Swoole\SwooleHandler;
|
||||||
use ZM\ConsoleApplication;
|
use ZM\ConsoleApplication;
|
||||||
@@ -36,7 +38,7 @@ try {
|
|||||||
$all_event_class = array_merge($all_event_class, ZMUtil::getClassesPsr4($autoload_path, $namespace));
|
$all_event_class = array_merge($all_event_class, ZMUtil::getClassesPsr4($autoload_path, $namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
$reader = new AnnotationReader();
|
$reader = new DualReader(new AnnotationReader(), new AttributeReader());
|
||||||
$event_list = [];
|
$event_list = [];
|
||||||
$setup_list = [];
|
$setup_list = [];
|
||||||
foreach ($all_event_class as $v) {
|
foreach ($all_event_class as $v) {
|
||||||
@@ -68,17 +70,3 @@ try {
|
|||||||
fclose($stderr);
|
fclose($stderr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
记迷惑,这里的代码是不是可以放到一个单独的文件里面,这样就不会出现每次都要重新加载的问题了?
|
|
||||||
然后这个文件就实现了,就是这个。
|
|
||||||
但是还有个什么问题呢?为了 reload 牺牲了太多太多,但是关键时刻好像又不是很能用到。
|
|
||||||
但又不能没有。
|
|
||||||
所以我很纠结很纠结。
|
|
||||||
如何让用户的代码能像 php-fpm 那样随时重置呢?
|
|
||||||
我不知道诶。
|
|
||||||
那这段代码干了个啥?
|
|
||||||
在最开始单独启动进程,加载一遍所有类,获取需要在启动前就执行的类,然后在启动的时候执行。
|
|
||||||
这样就可以不在爷进程里面加载所有类,在爹进程里面 Fork 的子进程再加载所有类,每次 reload 时可以重新加载了。
|
|
||||||
以上均为乱写的,请勿完全当真,本人对待框架代码还是比较认真的。
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user