Seneca-mesh CL MISSING

时间:2017-07-27 18:19:45

标签: seneca hapi.js

任何人都有塞内卡的经历吗?

当我尝试包括网格时我有问题...

这是hapi路线:

server.route({
        method: 'GET',
        path: '/api/ping',
        handler: function (req, reply) {

            server.seneca// load the mesh plugin
                .use('mesh')

                // send a message out into the network
                // the network will know where to send format:hex messages
                .act('foo:1,v:2', (err: any, out: any) => {
                    console.log(err)
                    // prints #FF0000
                    reply(null, out)
                })

        }
    })

这是我的服务:

require('seneca')({
})
  //.use('zipkin-tracer', {sampling:1})
  .use('entity')
  .use('ping-logic')

  .ready(function(){
    console.log(this.id)
  })

逻辑:

module.exports = function post(options) {
  var seneca = this

  seneca// provide an action for the format:hex pattern
  .add( 'foo:1', function (msg, done) {
    done( null, {x:1,v:100+msg.v} )
  })
  .use('mesh', { auto:true, pin:'foo:1' })
}

我收到错误

  

CL MISSING {foo:1,v:2}

任何人都知道什么是porblem?

1 个答案:

答案 0 :(得分:2)

我也遇到了这个问题。我必须做两件事:

  1. 使用seneca-mesh插件的master分支。不幸的是,NPM上发布的v0.10.0已经过时(2017年3月7日),并且不适用于seneca v3.4.x
  2. 在您的hapi路线中添加seneca.ready(function()),如下所示:

    server.route({
        method: 'GET',
        path: '/api/ping',
        handler: function (req, reply) {
    
        server.seneca// load the mesh plugin
            .use('mesh')
            .ready(function () {         
                // send a message out into the network
                // the network will know where to send format:hex messages
                this.act('foo:1,v:2', (err: any, out: any) => {
                    console.log(err)
                    // prints #FF0000
                    reply(null, out)
                })
            })             
        }
    })
    
  3. 同时检查这个相关的github问题,其中我询问了主要贡献者是否有计划在NPM上尽快获得新的修复版本: https://github.com/senecajs/seneca-mesh/issues/90

    希望这有帮助

相关问题