egg-pubsub
v0.0.3-beta
Published
provide google cloud pubsub for egg.js
Downloads
1
Maintainers
Readme
egg-pubsub
Install
$ npm i egg-pubsub --save
Usage
// {app_root}/config/plugin.js
exports.pubsub = {
enable: true,
package: 'egg-pubsub',
};
Configuration
// {app_root}/config/config.default.js
exports.pubsub = {
client: {
name: 'pubsubName',
/**
* @var topic google cloud topic name, it is optional.
*/
topic: 'topic name',
/**
* @var subscription google cloud subscription name, it is optional.
*/
subscription: 'subscribe name',
/**
* the document contains more detailed information about the settings of pubsub
* https://cloud.google.com/nodejs/docs/reference/pubsub/0.28.x/PubSub
*/
}
};
// {app_root}/pubsub/pubsubName.js
module.exports = pubsubApp => {
pubsubApp.router.register('test', async context => {
console.log(context.cmd);
});
}
// {app_root}/app/controller/home.js
const controller = require('egg').Controller;
class HomeController extends Controller {
async index() {
await this.app.pubsub.publish('test');
}
}
module.exports = HomeController;
see config/config.default.js for more detail.
Example
Questions & Suggestions
Please open an issue here.