Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API consistency for auto:false & ability to observe/consume on same port #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ The alias `m` can be used as a shortcut.
The _seneca-mesh_ plugin accepts the following set of options. Specify these when loading the plugin:

```js
require('seneca')
require('seneca')()
.use('mesh', {
// options go here
})
Expand Down
16 changes: 8 additions & 8 deletions mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,17 @@ function mesh (options) {

var pins = config.pins || config.pin || []
pins = _.isArray(pins) ? pins : [pins]
var client_config = _.omit(config, ['pins', 'pin'])

_.each(pins, function (pin) {
var pin_id = instance.util.pattern(pin)
var pin_id = instance.util.pattern(pin.pin || pin)
var has_balance_client = !!balance_map[pin_id]
var target_map = (balance_map[pin_id] = balance_map[pin_id] || {})

var pin_config = _.clone(config)
delete pin_config.pins
delete pin_config.pin

pin_config.pin = pin_id
var pin_config = _.extend({}, client_config, {
pin: pin_id,
model: pin.model || client_config.model
})

var id = instance.util.pattern(pin_config) + '~' + meta.identifier$

Expand All @@ -285,7 +285,7 @@ function mesh (options) {
pin_config.id = id

// TODO: how to handle local override?
var actmeta = instance.find(pin)
var actmeta = instance.find(pin_id)
var ignore_client = !!(actmeta && !actmeta.client)

if (ignore_client) {
Expand All @@ -295,7 +295,7 @@ function mesh (options) {

if (!has_balance_client) {
// no balancer for this pin, so add one
instance.root.client({type: 'balance', pin: pin, model: config.model})
instance.root.client({type: 'balance', pin: pin_id, model: pin_config.model})
}

target_map[id] = true
Expand Down