Comparing version 1.1.0 to 2.0.0
@@ -7,5 +7,5 @@ 'use strict'; | ||
app.ons = new ONS(app); | ||
app.beforeStart(function* () { | ||
yield app.ons.init(); | ||
app.beforeStart(async () => { | ||
await app.ons.init(); | ||
}); | ||
}; |
2.0.0 / 2018-07-26 | ||
================== | ||
**others** | ||
* [[`3a3b039`](http://github.com/eggjs/egg-ons/commit/3a3b03924d55210be49561fb84cfc0b8f2971ac3)] - refactor: use async await (Yiyu He <<dead_horse@qq.com>>) | ||
1.1.0 / 2018-05-03 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -24,3 +24,3 @@ 'use strict'; | ||
* init() { | ||
async init() { | ||
const { app } = this; | ||
@@ -35,7 +35,7 @@ const { sub, pub } = this.config; | ||
for (const options of sub) { | ||
yield this.createConsumer(options, app.ONSSubscribers); | ||
await this.createConsumer(options, app.ONSSubscribers); | ||
} | ||
for (const options of pub) { | ||
yield this.createProducer(options); | ||
await this.createProducer(options); | ||
} | ||
@@ -49,3 +49,3 @@ } | ||
* createConsumer(options, Subscribers) { | ||
async createConsumer(options, Subscribers) { | ||
const { app, consumerMap, logger, config } = this; | ||
@@ -61,7 +61,7 @@ const consumer = new Consumer(Object.assign({ | ||
yield consumer.ready(); | ||
await consumer.ready(); | ||
logger.info('[egg-ons] consumer: %s is ready, messageModel: %s', consumer.consumerGroup, consumer.messageModel); | ||
app.beforeClose(function* () { | ||
yield consumer.close(); | ||
app.beforeClose(async function() { | ||
await consumer.close(); | ||
logger.info('[egg-ons] consumer: %s is closed, messageModel: %s', consumer.consumerGroup, consumer.messageModel); | ||
@@ -78,6 +78,6 @@ }); | ||
consumer.subscribe(topic, Subscriber.subExpression || '*', function* (msg) { | ||
consumer.subscribe(topic, Subscriber.subExpression || '*', async function(msg) { | ||
const ctx = app.createAnonymousContext(); | ||
const subscriber = new Subscriber(ctx); | ||
yield subscriber.subscribe(msg); | ||
await subscriber.subscribe(msg); | ||
}); | ||
@@ -87,3 +87,3 @@ } | ||
* createProducer(options) { | ||
async createProducer(options) { | ||
const { app, producerMap, logger, config, topic2Producer } = this; | ||
@@ -103,7 +103,7 @@ const producer = new Producer(Object.assign({ | ||
yield producer.ready(); | ||
await producer.ready(); | ||
logger.info('[egg-ons] producer: %s is ready', producer.producerGroup); | ||
app.beforeClose(function* () { | ||
yield producer.close(); | ||
app.beforeClose(async function() { | ||
await producer.close(); | ||
logger.info('[egg-ons] producer: %s is closed', producer.producerGroup); | ||
@@ -113,9 +113,9 @@ }); | ||
* send(msg) { | ||
async send(msg) { | ||
assert(msg && msg.topic, '[egg-ons] send(msg) msg.topic is required'); | ||
const producer = this.topic2Producer.get(msg.topic); | ||
assert(producer, `[egg-ons] CANNOT find producer for topic=${msg.topic}`); | ||
return yield producer.send(msg); | ||
return await producer.send(msg); | ||
} | ||
}; | ||
{ | ||
"name": "egg-ons", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "aliyun ons plugin for egg", | ||
@@ -14,16 +14,16 @@ "eggPlugin": { | ||
"dependencies": { | ||
"ali-ons": "^2.0.2" | ||
"ali-ons": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"autod": "^2.10.1", | ||
"autod-egg": "^1.0.0", | ||
"egg": "^1.9.0", | ||
"egg-bin": "^4.3.5", | ||
"egg-mock": "^3.13.1", | ||
"eslint": "^4.9.0", | ||
"eslint-config-egg": "^5.1.1", | ||
"autod": "^3.0.1", | ||
"autod-egg": "^1.1.0", | ||
"egg": "^2.9.1", | ||
"egg-bin": "^4.7.1", | ||
"egg-mock": "^3.17.3", | ||
"eslint": "^5.2.0", | ||
"eslint-config-egg": "^7.0.0", | ||
"webstorm-disable-index": "^1.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=6.0.0" | ||
"node": ">=8.0.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13266
1
+ Addedali-ons@3.12.0(transitive)
+ Addedbyte@2.0.0(transitive)
+ Addedco-gather@1.0.1(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedlong@4.0.0(transitive)
+ Addedmkdirp@1.0.4(transitive)
- Removedali-ons@2.0.4(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.13.2.1(transitive)
- Removedbyte@1.4.1(transitive)
- Removedchalk@1.1.32.4.2(transitive)
- Removedcircular-json@0.5.9(transitive)
- Removedco-gather@0.0.1(transitive)
- Removedco-thread@0.0.1(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddepd@1.1.2(transitive)
- Removedegg-logger@1.8.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedlong@3.2.0(transitive)
- Removedms@2.0.0(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.05.5.0(transitive)
Updatedali-ons@^3.0.0