Giter Site home page Giter Site logo

swoft-cloud / swoft-component Goto Github PK

View Code? Open in Web Editor NEW
97.0 17.0 107.0 7.67 MB

📦 This is a repository of centralized management of all swoft core components

Home Page: https://www.swoft.org

License: Apache License 2.0

PHP 99.40% Shell 0.52% Makefile 0.05% Smarty 0.03%
swoole swoft aop coroutine microservice

swoft-component's Introduction

Swoft Component

Actions Status Build Status GitHub tag (latest SemVer)

This repository is used to manage all swoft core components.

中文说明请查看 README.zh-CN.md

IMPORTANT

All components will NOT be modified in the original repository of ext component, SHOULD ALWAYS be modified in this repository, also commit and push to this repository, and then @swoft-bot would sync changes to the original repository of component by git subtree push, notice that this action needs triggered by the repositories owner.

Usage

Add require to composer.json

"require": {
    "swoft/ext": "dev-master as 2.0"
}

Install:

composer update

Unit Tests

Quick run tests for component:

// For all components
./phpunit.sh all
// For multi components
./phpunit.sh db event
// For one component
./phpunit.sh event

Only tests an special component:

./phpunit.sh event
// use run.php
php run.php -c src/event/phpunit.xml
// filter test method name
php run.php -c src/event/phpunit.xml --filter testAddModule

Output coverage data:

// output coverage. require xdebug ext
phpunit --coverage-text
// output coverage without xdebug
phpdbg -dauto_globals_jit=Off -qrr /usr/local/bin/phpunit --coverage-text
phpdbg -dauto_globals_jit=Off -qrr run.php --coverage-text -c src/event/phpunit.xml

Releases

Please see https://github.com/swoftlabs/swoft-releasecli

Document

Discuss

Contributing

The development team welcomes you to submit PR (Pull Request) to us, but to ensure code quality and uniform style, go to the official main repository swoft/swoft and Development repository, Note the code and commit format when contributing code

Precautions when initiating PR

  • Please do not submit PR to each sub-repository, they are all read-only
  • The development repository for the core components is swoft/swoft-component
  • The development repository for extension components is swoft/swoft-ext
  • Please fork the corresponding development warehouse. After modification, please submit your PR to the corresponding development warehouse.

Officially syncs code to individual sub-warehouses when new versions are released

Commit Message

  • the commit message can only be in English
  • Please try to ensure that the commit message is meaningful
  • it is best to start with the keyword add: update: fix:

Code Style

  • Submitted PHP code Must Follow PSR-2 code style
  • Reasonable and meaningful class, method, variable naming
  • Appropriate comments, reasonable use of blank lines to keep the code simple and easy to read
  • Don't include some meaningless information such as @author, etc. (author is that can be seen from the commit log)

swoft-component's People

Contributors

adotpeng avatar andiechang avatar anhoder avatar aprchen avatar assert6 avatar carpcai avatar daydaygo avatar deivaliang avatar dependabot-preview[bot] avatar huangzhhui avatar hzmarico avatar inhere avatar kiilii avatar limingxinleo avatar luxin88 avatar no-serve-people avatar panyongwei avatar phpmathan avatar rlgy avatar sakuraovq avatar sentrychen avatar shixinke avatar stelin avatar swoft-bot avatar tanpeng avatar whiteccinn avatar wp-breeder avatar wujunze avatar wvfeng avatar xiangjihan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swoft-component's Issues

Request->json() 调用报错

PHP Warning: stripos() expects parameter 1 to be string, array given in /home/www-data/Project/swoft/vendor/swoft/http-message/src/Server/Concerns/InteractsWithInput.php on line 140

json方法中 stripos 调用 InteractsWithInput->getHeader 返回的数据,此方法返回数组

swoft-component/src/framework/src/Processor/EnvProcessor.php 配置后置方法定义错误

application->beforeEnv()) { CLog::warning('Stop env processor by beforeEnv return false'); return false; } $envFile = $this->application->getEnvFile(); $envFile = \alias($envFile); $path = \dirname($envFile); $env = \basename($envFile); if (!\file_exists($envFile)) { CLog::warning('Env file(%s) is not exist! skip load it', $envFile); return true; } // Load env $dotenv = new Dotenv($path, $env); $dotenv->load(); CLog::info('Env file(%s) is loaded', $envFile); return $this->application->afterEvent(); } } 配置类的后置方法afterEnv() 调用写成了 $this->application->afterEvent();

服务重启不成功

在生产环境运行,服务重启时偶尔不成功。经过初步排查定位为服务在停止时超时导致失败。 框架默认将超时时间设置为60秒。目前业务中有定时器任务,其执行时间超过60秒,导致停止超时。建议将服务停止时间设置为自定义,或者是将默认超时时间设定更长。

swoft-framework

swoft-framework
这个组件尽快发个tag出来吧,我写第三方扩展,比较依赖ComposerHelper这个工具类

😄

TCP_OPEN_EOF_CHECK 为true时,RPC调用将不可用

当TCP_OPEN_EOF_CHECK=true时,因为

    /**
     * @param string $data
     *
     * @return bool
     */
    public function send(string $data): bool
    {
        $result =  $this->connection->send($data);
        $this->recv = false;
        return $result;
    }

发送数据时,不是以\r\n结尾,所有onReceive就会一直阻塞等待。导致客户端调用失败。

这里希望尽快修改一下,要不然RPC调用时,消息一大,就会导致服务异常。

Resolve inject type from reflection property type for php 7.4

throw new BeanException('`@Inject` must be define inejct value or `@var type` ');

https://www.php.net/manual/reflectionproperty.gettype.php
For example:

/**
 * @Inject()
 */
private SomeInterface $someProperty;

Instead of

/**
 * @Inject(SomeInterface::class)
 */
private SomeInterface $someProperty;

Or more ugly

/**
 * @var SomeInterface
 */
private SomeInterface $someProperty;

restart的疑问

偶尔出现,restart项目的时候stop会卡住,然后中断指令,就会发现主进程退出了,但是子进程就像一个个孤儿一样,没人管了

各位大大,ProcessBuilder 这个类可否增加支持创建多个子进程

各位大大,ProcessBuilder 这个类可否增加支持创建多个子进程
因为我看swoft框架里面是这样的
@Process(name="getGoodProcess", coroutine=false,num=10)
但是目前组件不支持
以下是我修改后的

if($num > 1){
                $childProcesses = [];
                $pid = $process->getProcess()->pid;
                while($num > 0){
                    $child = new SwooleProcess(function (SwooleProcess $child) use ($process,$pid,$processObject,$num,$name) {
                        $child = new Process($child);
                        $child->name($name." child process");
                        PhpHelper::call([$processObject, 'run'], [$child]);
                    });
                    $child->name($name." manager process");
                    $child->start();
                    App::trigger(ProcessEvent::BEFORE_PROCESS, null, $name.":child:".$child->pid);
                    $num --;
                    $childProcesses[$pid][$child->pid] = 1;
                }
                Process::signal(SIGCHLD, function($sig) use ($childProcesses,$pid,$process,$name) {
                    //必须为false,非阻塞模式
                    while(1){
                        $ret =  Process::wait(false);
                        if($ret){
                            App::trigger(ProcessEvent::AFTER_PROCESS, null, $name.":child:".$ret['pid']);
                            unset($childProcesses[$pid][$ret['pid']]);
                            if(!$childProcesses[$pid]){
                                break;
                            }
                        }
                    }
                    if($childProcesses[$pid]){
                        foreach ($childProcesses[$pid] as $cid=>$v){
                            App::trigger(ProcessEvent::AFTER_PROCESS, null, $name.":child:".$cid);
                        }
                        unset($childProcesses[$pid]);
                    }
                    $process->exit();
                });
            }else{
                PhpHelper::call([$processObject, 'run'], [$process]);
            }

Originally posted by @liida in #153 (comment)

服务治理的疑问

我配了服务治理,使用consul

但是我调用rpc服务的时候,目标地址似乎没办法从consul上获取?

是我用的有啥问题么?这部分文档上也没有说的太明白。

我看源码这里,似乎RPC客户端获取服务地址时,只在pool获取

    public function createConnection()
    {
        $client = new Client(SWOOLE_SOCK_TCP | SWOOLE_KEEP);

        $address = $this->pool->getConnectionAddress();
        $timeout = $this->pool->getTimeout();
        list($host, $port) = explode(':', $address);
        if (!$client->connect($host, $port, $timeout)) {
            $error = sprintf('Service connect fail errorCode=%s host=%s port=%s', $client->errCode, $host, $port);
            App::error($error);
            throw new RpcClientException($error);
        }
        $this->connection = $client;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.