Skip to content

Commit

Permalink
feat(composer): remove Metoo
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed Mar 23, 2019
1 parent d9d2314 commit edffcbf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 124 deletions.
28 changes: 6 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _ __ __ _ _ __ _ _| |_ ___
An object-oriented multi process manager for PHP
Version: 0.3.5
Version: 0.5.0
```

Expand Down Expand Up @@ -36,34 +36,17 @@ composer create-project tigerb/naruto naruto --prefer-dist && cd naruto
### Business code

```php
use Naruto\Manager;
use Naruto\Process;
use Naruto\ProcessException;
use Exception as Ex;
use App\Demo\Test;

/**
* example
*
* $config = [
* 'passwd' => '123456', // unix user passwd
* 'worker_num' => 5, // worker start number,
* 'os' => 'Linux' // os type
* ]
* new Manager($config, $closure)
*/
$instance = new Manager([], function (Process $worker) {

new Manager([], function (Process $worker) {
// mock business logic
$instance = new Test();
$instance->businessLogic();
$instance->dbTest();
(new Test())->businessLogic();
}
);
```

### Run

> export NARUTO_PATH=$(pwd) && export PATH="$PATH:$NARUTO_PATH/bin"
> echo export NARUTO_PATH=$(pwd) >> ~/.profile && echo 'export PATH="$PATH:$NARUTO_PATH/bin"' >> ~/.profile && source ~/.profile
> composer install
Expand Down Expand Up @@ -91,5 +74,6 @@ naruto start/reload/quit/stop
- [x] Use a lightweight Orm [Metoo](https://github.com/catfan/Medoo)
- [x] Implement max execute times for the worker process
- [x] Add config file
- [x] Remove a lightweight Orm [Metoo](https://github.com/catfan/Medoo) for keep lightweight @2019/03/23
- [ ] Implement email send when the worker in a exception&error
- [ ] Add config reload strategy
18 changes: 0 additions & 18 deletions app/demo/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace App\Demo;

use Naruto\ProcessException;
use Medoo\Medoo;

class Test
{
Expand All @@ -28,21 +27,4 @@ public function businessLogic()
// mock business logic
usleep(1000000);
}

public function dbTest()
{
$db = new Medoo([
'database_type' => 'mysql',
'database_name' => 'naruto',
'server' => 'localhost',
'username' => 'naruto',
'password' => 'naruto'
]);

$db->insert('account', [
'username' => 'test',
'email' => 'test@test.com',
'password' => 'test'
]);
}
}
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
}
],
"require": {
"catfan/Medoo": "^1.5"
},
"autoload": {
"psr-4": {
Expand Down
78 changes: 0 additions & 78 deletions composer.lock

This file was deleted.

8 changes: 3 additions & 5 deletions naruto
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _ __ __ _ _ __ _ _| |_ ___

An object-oriented multi process manager for PHP

Version: 0.3.5
Version: 0.5.0
\n
HELP;

Expand Down Expand Up @@ -101,17 +101,15 @@ use App\Demo\Test;
* new Manager($config, $closure)
*/
try {
$instance = new Manager([
new Manager([
'os' => $input['os']?? 'Linux',
'passwd' => $input['passwd']?? '',
'worker_num' => $input['worker-num']?? 5,
// 'pipe_dir' => '/tmp/naruto/'
// 'hangup_loop_microtime' => 200000
], function (Process $worker) {
// mock business logic
$instance = new Test();
$instance->businessLogic();
// $instance->dbTest();
(new Test())->businessLogic();
}
);
} catch (Ex $e) {
Expand Down

0 comments on commit edffcbf

Please sign in to comment.