Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed Oct 19, 2017
1 parent 13324b7 commit a3f6407
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/source/en/basics/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,22 @@ We can get it via `ctx.coreLogger`, the difference between the Context Logger is

We can get them via `this.logger` in Controller and Service instance, they are essentially a Context Logger, but additional file path will be added to logs, easy to locate the log print location.

## Subscription

Subscription is the model for subscribing, including consumer in message broker or schedule.

The base class of Subscription is exported by egg.

```js
const Subscription = require('egg').Subscription;
class Schedule extends Subscription {
// This method should be implemented
* subscribe() {}
}
```

[Schedule](./schedule.md) is implemented using the model,also recommend the plugin for message broker.

[Koa]: http://koajs.com
[Koa.Application]: http://koajs.com/#application
[Koa.Context]: http://koajs.com/#context
Expand Down
16 changes: 16 additions & 0 deletions docs/source/zh-cn/basics/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,22 @@ module.exports = {

我们可以在 Controller 和 Service 实例上通过 `this.logger` 获取到它们,它们本质上就是一个 Context Logger,不过在打印日志的时候还会额外的加上文件路径,方便定位日志的打印位置。

## Subscription

Subscription 是一种订阅模型,消息中间件的消费者或调度任务都属于这种模式。

可以通过以下方式来引用 Subscription 基类:

```js
const Subscription = require('egg').Subscription;
class Schedule extends Subscription {
// 是需要实现此方法
* subscribe() {}
}
```

[定时任务](./schedule.md)使用这种模式实现,也建议使用此模型实现消息中间件。

[Koa]: http://koajs.com
[Koa.Application]: http://koajs.com/#application
[Koa.Context]: http://koajs.com/#context
Expand Down

0 comments on commit a3f6407

Please sign in to comment.