Skip to content

Commit

Permalink
Updates tong-bu-fu-wu/logri-zhi-lei.md
Browse files Browse the repository at this point in the history
Auto commit by GitBook Editor
  • Loading branch information
fucongcong committed Nov 8, 2017
1 parent feef331 commit b657f6a
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 30 deletions.
50 changes: 20 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,25 @@
* [注册中心](doc/fu-wu-zhong-xin/zhu-ce-zhong-xin.md)
* [服务调用](doc/fu-wu-zhong-xin/yi-bu-http-server-zhong-shi-yong-fu-wu.md)
* [服务调用监控](doc/fu-wu-zhong-xin/fu-wu-diao-yong-jian-kong.md)
* 基础服务(待更新)
* 基础服务\(待更新\)

* Config
* StaticCache
* Event

* Route

* Controller
* View

* Request

* Response
* 同步服务(用于服务开发)
* Event
* Listener
* Subscriber
* EventDispatcher

* 同步服务\(用于服务开发\)
* FileCache
* RedisCache
* Log
Expand Down Expand Up @@ -84,7 +95,6 @@
6. 启动http server => php server.php
7. 访问 [http://localhost:9777/](http://localhost:9777/) 开始异步协程之旅


### 异步Tcp客户端

#### 串行发包
Expand Down Expand Up @@ -123,7 +133,6 @@

###


### 异步Http客户端

#### Get方式
Expand Down Expand Up @@ -177,8 +186,6 @@

> ##### 注:若请求https地址,需要在编译swoole时开启openssl


### 异步Mysql客户端

#### AsyncMysql::query\($sql, $usePool = true\)
Expand Down Expand Up @@ -241,8 +248,6 @@
yield true;
}



### 异步Redis客户端

#### 连接池(连接池默认开启)
Expand All @@ -266,7 +271,7 @@

yield AsyncRedis::set('foo', 'bar');
dump(yield AsyncRedis::get('foo'));

$user = json_encode(['foo' => 'bar']);
yield AsyncRedis::hSet('user', 1, $user);
dump(yield AsyncRedis::hGet('user', 1));
Expand All @@ -282,7 +287,7 @@
//redis连接超时时间
'timeout' => 5,
'default' => [
'host' => '127.0.0.1',
'port' => 6379,
Expand All @@ -296,12 +301,9 @@

###



### 异步Log日志

```
use AsyncLog;
yield AsyncLog::info('hello world');
Expand All @@ -321,8 +323,6 @@
yield AsyncLog::emergency('hello world');
```



### 异步文件读写

#### 读文件
Expand All @@ -331,7 +331,6 @@
use AsyncFile;
$content = (yield AsyncFile::read(__ROOT__."runtime/test.txt"));
```

#### 写文件
Expand All @@ -344,8 +343,6 @@

> 目前仅支持小于4M的文件


### 异常Exception

#### 以传统的try,catch抓取异常
Expand All @@ -367,21 +364,19 @@

![](soa.png)



### 注册中心

#### 设置注册中心

修改config/service.php中的registry\_address.目前只支持Redis、Mysql注册中心
修改config/service.php中的registry\_address.目前只支持Redis、Mysql注册中心

##### Redis注册中心
##### Redis注册中心

```
'registry_address' => 'redis://127.0.0.1:6379'
```

##### Mysql注册中心
##### Mysql注册中心

```
//mysql注册中心,开启后,请执行doc/mysql-registry.sql中的sql,创建2张表
Expand Down Expand Up @@ -428,8 +423,6 @@ app/service user
],
```



### 在异步HTTP SERVER中使用服务

#### 全局方法service\_center\(\)
Expand Down Expand Up @@ -462,7 +455,7 @@ app/service user
$callId1 = $service->addCall("User::getUsersCache", ['ids' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]);
$callId2 = $service->addCall("User::getUser", ['id' => 1]);
$res = (yield $service->multiCall());
dump($res[$callId1]);
dump($res[$callId2]);
```
Expand Down Expand Up @@ -499,8 +492,6 @@ service\(\)不会通过注册中心发现服务
dump($res[$callId2]);
```



### 服务调用监控

#### KernalEvent::SERVICE\_CALL事件
Expand Down Expand Up @@ -538,4 +529,3 @@ service\(\)不会通过注册中心发现服务




7 changes: 7 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@
* [Listener监听类](doc/ji-chu-fu-wu/listenerjian-ting-lei.md)
* [Subscriber多事件监听](doc/ji-chu-fu-wu/subscriberduo-shi-jian-jian-ting.md)
* [EventDispatcher事件调度](doc/ji-chu-fu-wu/eventdispatchershi-jian-diao-du-lei.md)
* [同步服务\(Service开发\)](tong-bu-fu-wu.md)
* [Service](tong-bu-fu-wu/service.md)
* [Dao](tong-bu-fu-wu/dao.md)
* [Cache](tong-bu-fu-wu/rediscache.md)
* [Log日志类](tong-bu-fu-wu/logri-zhi-lei.md)
* [FileCache文件缓存类](tong-bu-fu-wu/filecachewen-jian-huan-cun-lei.md)
* [控制台](kong-zhi-tai.md)

42 changes: 42 additions & 0 deletions kong-zhi-tai.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
### 控制台

#### 命令进入根目录执行 app/console

```
- - - - - - - - - - - - - - - - - \ \ \ \ - - - - - -
/ - - - - - / \ / / - - - / / - - - - - \ \ \ \ \ \ \- - - - - -\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ - - - \ \ \ \ \ \ \ \ \ \ \ \- - - - - / /
\ \ / - - -/ \ \ \ \ \ \ \ \ \ \ \ \ - - - - -
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ - - - \ \ \ \ \ \ - - - - - / \ \ - - - - \ \ \
\ - -- - \ / \ \ \ - - - - -/ \ - - - - - / \ \
使用帮助:
Usage: app/console [options] [args...]
generate:service name 生成一个自定义service
generate:controller name|groupname:name 生成一个自定义controller(默认存放在src/Web,如果想要指定分组 groupname:name)
sql:generate 生成一个sql执行模板(存放于app/sql)
sql:migrate 执行sql更新
sql:rollback version 执行sql回滚到指定版本
log.clear 清除日志
```

#### 自定义控制台 {#自定义控制台}

##### 配置文件config/app.php {#配置文件configappphp}

```
//扩展console命令行控制台
'console_commands' => [
'log:clear' => [
'command' => 'src\Web\Command\LogClearCommand', //执行的类
'help' => '清除日志', //提示
],
],
```



Empty file added tong-bu-fu-wu.md
Empty file.
4 changes: 4 additions & 0 deletions tong-bu-fu-wu/dao.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Dao



6 changes: 6 additions & 0 deletions tong-bu-fu-wu/filecachewen-jian-huan-cun-lei.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### FileCache

###



4 changes: 4 additions & 0 deletions tong-bu-fu-wu/logri-zhi-lei.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Log



4 changes: 4 additions & 0 deletions tong-bu-fu-wu/rediscache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Cache



4 changes: 4 additions & 0 deletions tong-bu-fu-wu/service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Service服务



0 comments on commit b657f6a

Please sign in to comment.