diff --git a/README.md b/README.md index 0396245..0e7161e 100644 --- a/README.md +++ b/README.md @@ -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 }) diff --git a/mesh.js b/mesh.js index 44cc370..236bd50 100644 --- a/mesh.js +++ b/mesh.js @@ -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$ @@ -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) { @@ -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