This package has been deprecated

Author message:

migrate to @sigodenjs/dee-natstreaming

@sigodenjs/dee-natstream
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

Dee-Natstreaming 框架

Usage

  1. dee 中添加配置项
services: {
    mq: {
        constructor: 'natstream',
        constructorArgs: {
            templatePath: require('./template.json'),
            handlers: require('./handlers')
        }
    }
}
  1. 编写 template.json
{
  "client": {
    "clusterId": "test-cluster",
    "server": "nats://localhost:4222"
  },
  "producers": {
    "<name>": {
      // fastest-validator validate pubilsh msg
      "schema": {
        "id": { "type": "number", "positive": true, "integer": true },
      }
    }
  },
  "subscribers": {
    "<service.name>": {
      "group": true,
      "durable": true,
      "noAutoAck": true,
      "maxInFlight": 16384,
      "ackWait": 30
    }
  }
}
  1. 编写 handlers
module.exports = {
      'mysrv.sayHello': function(ctx) {
          ctx.srvs
      }
}
  1. 发送消息
srvs.mq.send('sayHello', { name: 'abc' }, function(err, cb) {

})
srvs.mq.send('sayHello', { name: 'abc' }).then(function(data) {

})

Package Sidebar

Install

npm i @sigodenjs/dee-natstream

Weekly Downloads

3

Version

0.1.4

License

MIT

Unpacked Size

8.42 kB

Total Files

5

Last publish

Collaborators

  • sigoden