Generate rpc client

@param {Object} app current application context
@param {Object} opts contructor parameters for rpc client
@return {Object} rpc client
353608
function(app, opts) {
  opts.context = app;
  opts.routeContext = app;
  if(!!opts.rpcClient) {
    return opts.rpcClient.create(opts);
  } else {
    return Client.create(opts);
  }
}
1252043
function generateApplicationCode(swagger, codegenOptions) {
  debug('Generating application code.');

  // Build up the execution parameters for the templates.
  const templateFunc = codegenOptions.templateSet;
  const outputDirectory = codegenOptions.temporaryDirectory;
  const codegenSettings = defaults(
    templateFunc(codegenOptions.templateSettings),
    {
      output: (name, content) => {
        const fullName = path.join(outputDirectory, name);
        const parsed = path.parse(fullName);
        mkdirp.sync(parsed.dir);
        fs.writeFileSync(fullName, content);
      },
      swagger: JSON.parse(JSON.stringify(swagger)), // Clone to avoid issues
    });

  // Perform the actual code generation
  codegen(codegenSettings);
}
445071
function resolveApps (opts) {
    const handler = strategies[opts.strategy];
    if (!handler) {
      throw Error('invalid suggestion strategy');
    }
    return handler(opts);
  }
1007561
def get_app(opts):
    '''
    
    '''
    apiopts = opts.get(__name__.rsplit('.', 2)[-2], {})  # rest_cherrypy opts

    # Add Salt and salt-api config options to the main CherryPy config dict
    cherrypy.config['saltopts'] = opts
    cherrypy.config['apiopts'] = apiopts

    root = API()  # cherrypy app
    cpyopts = root.get_conf()  # cherrypy app opts

    return root, apiopts, cpyopts
324656
function Client(svc, opts) {
  opts = opts || {};
  events.EventEmitter.call(this);

  // We have to suffix all client properties to be safe, since the message
  // names aren't prefixed with clients (unlike servers).
  this._svc$ = svc;
  this._channels$ = []; // Active channels.
  this._fns$ = []; // Middleware functions.

  this._buffering$ = !!opts.buffering;
  this._cache$ = opts.cache || {}; // For backwards compatibility.
  this._policy$ = opts.channelPolicy;
  this._strict$ = !!opts.strictTypes;
  this._timeout$ = utils.getOption(opts, 'timeout', 10000);

  if (opts.remoteProtocols) {
    insertRemoteProtocols(this._cache$, opts.remoteProtocols, svc, true);
  }

  this._svc$.messages.forEach(function (msg) {
    this[msg.name] = this._createMessageHandler$(msg);
  }, this);
}
1040858
function(app, opts) {
  this.app = app;
  this.opts = opts;
  this.client = genRpcClient(this.app, opts);
  this.app.event.on(events.ADD_SERVERS, this.addServers.bind(this));
  this.app.event.on(events.REMOVE_SERVERS, this.removeServers.bind(this));
  this.app.event.on(events.REPLACE_SERVERS, this.replaceServers.bind(this));
}
1345475
function(app, opts) {
  opts = opts || {};
  this.app = app;
  this.service = new SessionService(opts);

  let getFun = function(m) {
    return (function() {
          return function() {
            return self.service[m].apply(self.service, arguments);
          };
    })();
  };
  // proxy the service methods except the lifecycle interfaces of component
  let method, self = this;
  for(let m in this.service) {
    if(m !== 'start' && m !== 'stop') {
      method = this.service[m];
      if(typeof method === 'function') {
        this[m] = getFun(m);
      }
    }
  }
}
804872
function Client(app) {
  if (!(this instanceof Client)) return new Client(app);
  this._base = '';
  this._url = '';
  this.serialize = serializers.raw;
  this.parse = parsers.raw;
  this.middlewares = [];
  this.expectations = [];
  this.options = {
    followRedirect: false,
    method: 'GET',
    headers: {}
  };

  if (app) this.app(app);
}
525140
function Gateway(opts) {

    this.controllers = []; // Hold controller objectHandler by device name
    this.activeClients = []; // Hold all active clients sort by uid

    // Add DebugTool to log messages
    this.uid  = "Gateway:" + opts.name;
    this.debug =  opts.debug;   
    
    // simple counter for job queue
    this.request = 1;
    
    // Database backend and user event handler are shared amont all servers
    this.event = new EventEmitter();
    this.opts     = opts;
    
    // Compute some opts and provide some defaults
    this.opts.name       = opts.name         || "Gateway-Track";
    this.opts.debug      = opts.debug        || 1;      // default 1
    this.opts.backend    = opts.backend      || "file"; // file-backend.js
    this.opts.inactivity = opts.inactivity   || 600;    // default 10mn
      
    // Call constructor
    this.Gateway (opts);
}
151627
function Dispatcher (opts) {
    // provide some default value
    this.opts=
        { debug      : opts.debug    || 3              // default no debug
        , dumpfile   : opts.dumpfile || null           // filename for log file or NMEA generated commands
        , hostname   : opts.hostname || 'localhost'    // default localhost for client connect host
        , srvmod     : opts.srvmod   || false          // default is client mode
        , port       : opts.port     || 1234           // no default for port
        , cltmod     : opts.cltmod   || true           // default mode is client connect
        , timeout    : opts.timeout*1000  || 180000    // reconnect timeout default 180s
    };

    // verbose flag is global
    if (opts.verbose) Verbose = true;

    // if needed check dumpfile can be create
    if (this.opts.dumpfile !== null) {
        try { // dump fd is global
            DumpFD= fs.openSync (this.opts.dumpfile, "w+");
        } catch (err) {
            console.log ("hoops file to open [%s] err=[%s]",this.opts.dumpfile, err);
        }
    }

    // if needed start a Tcp server
    if (this.opts.srvmod) {
        this.opts.cltmod=false;    // when server cannot be a client
        this.TcpServer (); // start a server waiting on --port/localhost
    }

    // in client mode we connect onto a remote server
    if (this.opts.cltmod) {
        this.TcpClient();  // when connected will enter ClientListener() event handler
    }

    // validate Queue where position will be posted
     QJhandle  = async.queue  (QJpost, 1);
}
1207530
function(app, opts) {
  this.app = app;
  this.handlerMap = {};
  if(!!opts.reloadHandlers) {
    watchHandlers(app, this.handlerMap);
  }

  this.enableForwardLog = opts.enableForwardLog || false;
}
918130
def rpc(rpc_method, attrs={}, req_opts=nil)
      body = Encoding.encode_json(attrs)

      resp = self.class.make_http_request(@conn, @service_full_name, rpc_method, Encoding::JSON, req_opts, body)
      if resp.status != 200
        return ClientResp.new(nil, self.class.error_from_response(resp))
      end

      data = Encoding.decode_json(resp.body)
      return ClientResp.new(data, nil)
    end
598680
function (opts) {
    this.options = opts || {};
    this.pattern = null;
    this.middleware = {};
    this.includes = {};
    this.excludes = {};
    this.files = [];
    this.fns = [];

    options(this);
    iterators(this);
    symlinks(this);
    readers(this);
  }
1133652
function Connection(opts) {

    EventEmitter.call(this);

    opts = opts || {};

    _.defaults(opts, {
        host: 'localhost',
        port: '11211',
        reconnect: true,
        maxValueSize: 1048576
    });

    this.host = opts.host;
    this.port = opts.port;

    this.commandBuffer = new Immutable.List();

    if (opts.onConnect) {
        this.onConnect = opts.onConnect;
    }

    if (opts.onError) {
        this.onError = opts.onError;
    } else {
        this.onError = function onError(err) { this.emit('error'); console.error(err); };
    }
    this.bufferBeforeError = opts.bufferBeforeError;
    this.netTimeout = opts.netTimeout || 500;
    this.backoffLimit = opts.backoffLimit || 10000;
    this.reconnect = opts.reconnect;
    this.disconnecting = false;
    this.ready = false;
    this.backoff = opts.backoff || 10;
    this.maxValueSize = opts.maxValueSize;
    this.writeBuffer = new Immutable.List();

    this.connect();
}
507711
function API(opts) {
  opts = opts || {};

  this.verbose = !!opts.verbose;
  this.request = opts.request || request;
  this.baseUrl = opts.baseUrl || BASE_URL;
  var parsedUrl = url.parse(this.baseUrl);
  this.basePath = parsedUrl.path;
  this.baseHost = parsedUrl.protocol + '//' + parsedUrl.host;
  this.timeout = opts.timeout || 50000;

  if (this.verbose) {
    log.setLevel('debug');
  } else {
    log.setLevel('info');
  }
}
1329474
async def Set(self, application, options):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Application',
                   request='Set',
                   version=8,
                   params=_params)
        _params['application'] = application
        _params['options'] = options
        reply = await self.rpc(msg)
        return reply
1218753
function gulpPlovr(opts) {
  opts = opts || { };
  
  if (!opts.java_path) opts.java_path = JAVA_PATH;
  if (!opts.plovr_path) opts.plovr_path = PLOVR_PATH;
  if (!opts.plovr_args) opts.plovr_args = {};
  if (opts.debug) gutil.log(PLUGIN_NAME + ':', 'debug mode is enabled!');
  
  // Creating a stream through which each file will pass
  return through.obj(function(file, enc, cb) {
    if (file.isNull()) {
      // return empty file
      cb(null, file);
    }
    
    //var baseDir = path.dirname(module.parent.filename);
    var filePath = path.dirname(file.path);
    var configPath = file.path;
    
    if (file.isBuffer()) {
      var args = [];
      args.push('-jar');
      args.push(opts.plovr_path);
      
      Object.keys(opts.plovr_args).forEach(function(key) {
        var value;
        value = opts.plovr_args[key];
        args.push("--" + key);
        return args.push(value);
      });
      
      args.push('build');
      args.push(configPath);
      
      var compiler = spawn(opts.java_path, args);
      var stdout = '';
      var stderr = '';
      compiler.stdout.setEncoding('utf8');
      compiler.stderr.setEncoding('utf8');
      compiler.stdout.on('data', function(data) {
        if (opts.debug) gutil.log(PLUGIN_NAME + ':', data);
        return stdout += data;
      });
      
      compiler.stderr.on('data', function(data) {
        return stderr += data;
      });
      
      compiler.on('exit', function(code) {
        if (code !== 0) {
          this.emit('error', new gutil.PluginError(PLUGIN_NAME, stderr));
        }
        
        cb();
      });
      
      compiler.on('close', function(code) {
        if (opts.debug) gutil.log(stdout + stderr);
      });
    }
    
    if (file.isStream()) {
      this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
      cb();
    }
  });
}