/* eslint-disable complexity 
Get publish options for the message to send to amqplib's publish call
@private
334131
function getPublishOptions(message){
    let publishOptions = {
      type: message.type || '',
      contentType: message.contentType,
      contentEncoding: message.contentEncoding,
      correlationId: message.correlationId || '',
      replyTo: message.replyTo || '',
      messageId: message.messageId || message.id || '',
      timestamp: message.timestamp,
      appId: message.appId || '',
      headers: message.headers || {},
      expiration: message.expiresAfter || undefined,
      persistent: message.persistent !== false
    };
    if (publishOptions.replyTo === 'amq.rabbitmq.reply-to') {
      publishOptions.headers['direct-reply-to'] = 'true';
    }
    return publishOptions;
  }
525737
function (next) {

									minify(
										outputJsFile,
										_.extend({optimize: true},uglifyOptions),
										function(err){
											if ( err ){
												return next(err);
											}

											if ( isForPublish ){
												publisher(
													outputJsFile,
													function (err) {
														return next(err);
													},
													options.forceminified
												);
											}else {
												return next();
											}

										}
									);

								}
950494
def publish_message(host, amqp_settings, routing_key, data, async=False):
    
    global _thread
    global _num_pending

    kwargs = {
        "host": host,
        "amqp_settings": amqp_settings,
        "routing_key": routing_key,
        "data": data
    }

    if not async:
        return _publish_message(**kwargs)

    if _thread is None:
        with _lock:
            if _thread is None:
                _thread = threading.Thread(target=_publish_messages_async)
                _thread.daemon = True
                _thread.start()

    with _lock:
        _num_pending += 1

    _queue.put(kwargs)
    return True
706223
async function setup (payload, ...args) {
    let msg = await store.logon(payload);
    prtUtil.print(`Logon status: ${msg}`);
    debugger;
    let {compute, casManagement, modelPublish, files} = await store.addServices(...args);
    console.log(store.getServices());
    
    let r = store.getXsrfData();
    console.log('current xsrf tokens');
    console.log(r);

    console.log()
    let s = store.rafObject('modelPublish');
   // console.log(s);

    console.log(JSON.stringify(modelPublish.links('getPublishedModel'), null, 4));
    payload = {
        qs: {
            limit: 1000
        }
    }
    debugger;
    r = await store.apiCall(modelPublish.links('getPublishedModel'), payload);

    console.log(JSON.stringify(r.items(), null, 4));

    console.log(JSON.stringify(files.links('files', 'link'), null, 4));

    store.endStore();
    console.log(store.getServices());
    return true;
    }
26056
function PubConnection (node) {
  let connection = new EventEmitter()

  const _debug = D('dnsmq-messagebus:PUB')
  const debug = (...args) => _debug(node.name, ...args)

  let _socket = null
  let _connectingMaster = null

  /**
   * Provides a pub socket connecting to master.endpoint
   * @private
   * @param  {object} master - Map of properties about the actual master node
   * @return {object} A `zeromq` socket
   */
  const _getSocket = (master) => {
    let socket = zmq.socket('pub')
    socket._master = master
    socket.monitor(5, 0)
    socket.connect(master.endpoint)
    return socket
  }
  const _publishStream = new EventEmitter()
  _publishStream.on('message', (...args) => {
    if (_socket) _socket.send(args)
  })

  /**
   * creates a new pub socket and tries to connect it to the provided master;
   * after connection the socket is used to publish messages in the bus
   * and an eventual previous socket is closed
   * @param  {object} master
   * @return {object} the publishConnection instance
   */
  function connect (master) {
    if (_socket && _socket._master.name === master.name) {
      debug(`already connected to master ${master.name}`)
      return
    }
    if (_connectingMaster && _connectingMaster.name === master.name) {
      debug(`already connecting to master ${master.name}`)
      return
    }

    _connectingMaster = master
    let newSocket = _getSocket(master)

    let _messagesToResend = []
    let _onMessagePublished = (...args) => {
      if (_socket) _messagesToResend.push(args)
    }
    _publishStream.on('message', _onMessagePublished)

    debug(`connecting to ${master.name} at ${master.endpoint}`)

    let connectionStart = Date.now()
    const onSocketConnected = timingoutCallback((err) => {
      _publishStream.removeListener('message', _onMessagePublished)
      newSocket.unmonitor()

      if (
        err ||
        !_connectingMaster ||
        _connectingMaster.name === !master.name
      ) {
        newSocket.close()
        if (err) {
          debug(`failed to connect to ${master.name} at ${master.endpoint}`)
          disconnect()
        }
        return
      }

      _connectingMaster = null
      let previousSocket = _socket

      debug(`${previousSocket ? 'switched' : 'connected'} to ${master.name} at ${master.endpoint} in ${Date.now() - connectionStart} ms`)

      _socket = newSocket

      let totalMessagesToResend = _messagesToResend.length
      if (totalMessagesToResend) {
        debug(`resending ${totalMessagesToResend} messages published while transitioning`)
        _messagesToResend.forEach(message => _socket.send(message))
      }

      if (previousSocket) {
        previousSocket.close()
        debug(`closed previous connection to ${previousSocket._master.name} at ${previousSocket._master.endpoint}`)
      } else {
        connection.emit('connect')
      }
    }, 500)

    newSocket.once('connect', () => onSocketConnected())
    return connection
  }
  /**
   * if present, closes the pub socket
   * @return {object} the publishConnection instance
   */
  function disconnect () {
    _connectingMaster = null
    if (_socket) {
      _socket.close()
      _socket = null
      debug('disconnected')
      connection.emit('disconnect')
    }
    return connection
  }
  /**
   * takes a list of strings|buffers to publish as message's frames
   * in the channel passed as first argument;
   * decorates each message with a uid
   * @param  {string} channel
   * @param  {[string|buffer]} args
   */
  function publish (channel, ...args) {
    _publishStream.emit('message', channel, uniqueId(`${node.name}_`), ...args)
  }

  return Object.defineProperties(connection, {
    connected: {get: () => !!_socket},
    master: {get: () => _socket && {..._socket._master}},
    connect: {value: connect},
    disconnect: {value: disconnect},
    publish: {value: publish}
  })
}
1228851
function FilteraddMessage(arg, options) {
  Message.call(this, options);
  this.command = 'filteradd';
  $.checkArgument(
    _.isUndefined(arg) || BufferUtil.isBuffer(arg),
    'First argument is expected to be a Buffer or undefined'
  );
  this.data = arg || BufferUtil.EMPTY_BUFFER;
}
796564
function rollbackPublish() {
			try {
				chkoutRun(options.distBranch, function() {
					var cph = cmd('git rev-parse HEAD');
					if (pubHash && pubHash !== cph) {
						cmd('git checkout -qf ' + pubHash);
						cmd('git commit -q -m "Rollback: ' + tmpltData.distBranchPubMsg + '"');
						cmd('git push -f ' + options.repoName + ' ' + options.distBranch);
					} else if (!pubHash) {
						cmd('git push ' + options.repoName + ' --delete ' + options.distBranch);
					} else {
						rbot.log.verbose('Skipping rollback for ' + options.distBranch + ' for hash "' + pubHash
								+ '" (current hash: "' + cph + '")');
					}
				});
			} catch (e) {
				var msg = 'Failed to rollback publish branch changes!';
				rollCall.error(msg, e);
			}
		}
9443
function(product, options, callback) {

            if (arguments.length === 2) {
                callback = options;
                options = null;
            }

            if (options && options.clone) {
                product = product.clone(options.clone);
            }

            var bus = this.$.bus,
                self = this;

            //noinspection JSValidateTypes
            flow()
                .seq(function(cb) {
                    self.$.context.getCollection("printTypes").fetch({
                        fullData: true
                    }, cb);
                })
                .seq(function(cb) {
                    bus.setUp(product);
                    product.init(cb);
                })
                .exec(function(err) {
                    callback && callback(err, product);
                });
        }
1170510
function _getSplitParams(elem, tmplRule, outputH) {
  var extensionRule = tmplRule.extensionRule,
      startRule = tmplRule.startRule,
      endRule = tmplRule.endRule,
      firstChar = tmplRule.firstChar,
      lastChar = tmplRule.lastChar,
      spreadProp = tmplRule.spreadProp,
      directives = tmplRule.directives;
  var paramsEx; //Replace the parameter like "{...props}".

  elem = elem.replace(spreadProp, function (all, g1, propR, g3, prop) {
    if (propR) {
      prop = propR;
    }

    if (!paramsEx) {
      paramsEx = [extensionRule + 'props'];
    }

    paramsEx.push([extensionRule + 'spread ' + (propR ? firstChar : '') + startRule + prop.replace(/\.\.\./, '') + endRule + (propR ? lastChar : '') + '/']);
    return ' ';
  }); //Replace the parameter like "#show={false}".

  elem = elem.replace(directives, function (all, g1, g2, g3, g4, g5, g6, key, hasColon, hasEx, name, hasEqual, value) {
    if (hasEx == null) {
      return all;
    }

    if (!paramsEx) {
      paramsEx = [extensionRule + 'props'];
    }

    var args, modifiers;
    name = name.replace(REGEX_EX_ATTR, function (all, name, modifier, g3, arg) {
      if (arg) {
        args = arg.substr(1).split('-').map(function (item) {
          var argStr;
          var modifierStr = '';
          var strs = item.split(/[$.]/);
          strs.forEach(function (str, i) {
            if (i == 0) {
              argStr = 'name:\'' + str + '\'' + (i < strs.length - 1 ? ',' : '');
            } else {
              modifierStr += '\'' + str + '\'' + (i < strs.length - 1 ? ',' : '');
            }
          });
          return '{' + argStr + (modifierStr != '' ? 'modifiers:[' + modifierStr + ']' : '') + '}';
        });
      }

      if (modifier) {
        modifiers = modifier.substr(1).split(/[$.]/).map(function (item) {
          return '\'' + item + '\'';
        });
      }

      return name;
    });
    var exPreAst = [extensionRule + name + ' _njIsDirective' + (args ? ' arguments="' + firstChar + startRule + '[' + args.join(',') + ']' + endRule + lastChar + '"' : '') + (modifiers ? ' modifiers="' + startRule + '[' + modifiers.join(',') + ']' + endRule + '"' : '') + (hasEqual ? '' : ' /')];
    hasEqual && exPreAst.push((hasColon ? (outputH ? firstChar : '') + startRule + ' ' : '') + clearQuot(value) + (hasColon ? ' ' + endRule + (outputH ? lastChar : '') : ''));
    paramsEx.push(exPreAst);
    return ' ';
  });
  return {
    elem: elem,
    params: paramsEx
  };
}
638851
def publish_to_optional_targets(options = {})
      notifiable.optional_targets(target.to_resources_name, key).map { |optional_target|
        optional_target_name = optional_target.to_optional_target_name
        if optional_target_subscribed?(optional_target_name)
          optional_target.notify(self, options[optional_target_name] || {})
          [optional_target_name, true]
        else
          [optional_target_name, false]
        end
      }.to_h
    end
390077
function publish (channel, ...args) {
    if (!isString(channel)) throw new TypeError(`${_debugStr}: .publish(channel, [...args]) channel MUST be a string`)
    if (~internalChannels.indexOf(channel)) {
      console.warn(`${_debugStr} channel '${channel}' is used internally and you cannot publish in it`)
      return node
    }
    if (!_pubConnection.connected) {
      console.warn(`${_debugStr} cannot publish on bus.`)
      return node
    }
    _pubConnection.publish(channel, ...args)
    return node
  }
1318024
function setAndPublish(variableName, object, channel, option){

    client.set(variableName, JSON.stringify(object));
    // Publish that it did an update
    client.publish(channel, option);
}
141967
def publish(self, message):
        
        return self.client.publish_to_queue(self.name, message=message)
164156
function publishAreaVisibility() {
      const showing = visibilityIsChanging ? !$scope.model.areaShowing : $scope.model.areaShowing;
      return visibility.updateAreaVisibility( { [ $scope.features.area.name ]: showing } );
   }
932528
function (options, callback) {
    if (!callback) {
      callback = options;
      options = {};
    }

    var self = this;

    this.sagaStore.getTimeoutedSagas(options, function (err, sagas) {
      if (err) {
        debug(err);
        return callback(err);
      }

      var sagaModels = [];
      sagas.forEach(function (s) {
        var sagaModel = new SagaModel(s.id);
        sagaModel.set(s);
        sagaModel.actionOnCommit = 'update';

        var calledAddCommandToSend = false;
        sagaModel.addCommandToSend = function (cmd) {
          calledAddCommandToSend = true;
          sagaModel.addUnsentCommand(cmd);
        };
        var calledRemoveTimeout = false;
        var orgRemoveTimeout = sagaModel.removeTimeout;
        sagaModel.removeTimeout = function () {
          calledRemoveTimeout = true;
          orgRemoveTimeout.bind(sagaModel)();
        };
        sagaModel.commit = function (clb) {
          var cmds = calledAddCommandToSend ? sagaModel.getUndispatchedCommands() : [];

          function onAfterCommit(err) {
            if (err) return clb(err);

            function setCommandToDispatched (c, cb) {
              debug('set command to dispatched');
              self.setCommandToDispatched(dotty.get(c, self.definitions.command.id), sagaModel.id, function (err) {
                if (err) {
                  return cb(err);
                }
                sagaModel.removeUnsentCommand(c);
                cb(null);
              });
            }

            if (!self.onCommandHandle) return clb(null);

            async.each(sagaModel.getUndispatchedCommands(), function (cmd, callback) {
              debug('publish a command');
              self.onCommandHandle(cmd, function (err) {
                if (err) {
                  debug(err);
                  return callback(err);
                }
                setCommandToDispatched(cmd, callback);
              });
            }, clb);
          }

          async.each(cmds, function (cmd, fn) {
            if (dotty.exists(cmd, self.definitions.command.id)) {
              return fn(null);
            }

            self.getNewId(function (err, id) {
              if (err) {
                debug(err);
                return fn(err);
              }
              dotty.put(cmd, self.definitions.command.id, id);
              fn(null);
            });
          }, function (err) {
            if (err) {
              debug(err);
              return callback(err);
            }

            if (sagaModel.isDestroyed()) {
              self.removeSaga(sagaModel, onAfterCommit);
            } else if (calledAddCommandToSend) {
              sagaModel.setCommitStamp(new Date());
              var undispCmds = _.map(sagaModel.getUndispatchedCommands(), function (c) {
                return { id: dotty.get(c, self.definitions.command.id), payload: c };
              });
              self.sagaStore.save(sagaModel.toJSON(), undispCmds, onAfterCommit);
            } else if (calledRemoveTimeout) {
              sagaModel.setCommitStamp(new Date());
              self.sagaStore.save(sagaModel.toJSON(), [], onAfterCommit);
            } else {
              var err = new Error('Use commit only to remove a saga or to addCommandToSend!');
              debug(err);
              if (clb) { return clb(err); }
              throw err;
            }
          });
        };
        sagaModels.push(sagaModel);
      });

      callback(null, sagaModels);
    });
  }
628716
function publishedVers(name) {
        var _child$spawnSync = _child_process2['default'].spawnSync(npmCommand, ['view', name, 'versions', '--json']);

        var stdout = _child$spawnSync.stdout;
        var error = _child$spawnSync.error;

        if (error) throw error;

        return JSON.parse(stdout.toString());
    }
315582
protected function publish(AMQPMessage $message, $exchangeQueue, $routingKey, $publishChannels)
    {
        foreach ($publishChannels as $channel) {
            $channel->basic_publish($message, $exchangeQueue, $routingKey);
        }
    }