Decorator for RPC methods
@protected
357623
function rpc(functionName, ...datatypes) {
  const qrpc = qtypes.QInt.from(Types.RPCCALL);
  const qfunctionName = qtypes.QByteArray.from(`2${functionName}`);
  return function(target, _key, descriptor) {
    return {
      enumerable: false,
      configurable: false,
      writable: false,
      value: function(...args) {
        const data = descriptor.value.apply(this, args);
        this.qtsocket.write([
          qrpc,
          qfunctionName,
          ...data.map((value, index) => datatypes[index].from(value))
        ]);
      }
    };
  };
}
201697
def call_and_wrap(func, *args, **kw):
    '''
    '''
    try:
        return func(*args, **kw)
    except api.exceptions.APIException as ex:
        click_exception(ex)
    except urllib3exc.SSLError:
        # see monkey patch above re InsecurePlatformWarning
        if _insecure_warning:
            click.echo(click.style(str(_insecure_warning[0]), fg='red'))
        raise
860
def rpc_call(self, request, method=None, params=None, **kwargs):
        
        args = []
        kwargs = dict()
        if isinstance(params, dict):
            kwargs.update(params)
        else:
            args = list(as_tuple(params))

        method_key = "{0}.{1}".format(self.scheme_name, method)
        if method_key not in self.methods:
            raise AssertionError("Unknown method: {0}".format(method))
        method = self.methods[method_key]

        if hasattr(method, 'request'):
            args.insert(0, request)

        return method(*args, **kwargs)
968373
function subscribe() {
    console.log(' > ', 'init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123']);
    rpcClient.methodCall('init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123'], function (err, res) {
        console.log(err, res);
    });
}
1324310
def scoped_session_decorator(func):
    """"""

    @wraps(func)
    def wrapper(*args, **kwargs):
        with sessions_scope(session):
            # The session used in func comes from the funcs globals, but
            # it will be a proxied thread local var from the session
            # registry, and will therefore be identical to the one returned
            # by the context manager above.
            logger.debug("Running worker %s in scoped DB session", func.__name__)
            return func(*args, **kwargs)

    return wrapper
287027
function methodWrapper(fn) {
  return function() {
    var args = [].slice.call(arguments);
    args.unshift(this);
    return fn.apply(this, args);
  };
}
674919
function wrapQueryMethod(method) {
  Druid.prototype[method] = function(query, callback) {
    if (!this.ready) {
      var self = this
        , onready
        , onerror

      onready = function() {
        self.removeListener('error', onerror)
        self[method](query, callback)
      }

      onerror = function(err) {
        self.removeListener('ready', onready)
        callback(err)
      }

      this.once('ready', onready)
      this.once('error', onerror)

      return
    }

    var ds = query.dataSource()

    if (!this.dataSources.hasOwnProperty(ds)) {
      callback(new DruidError('No node serves data source: ' + ds))
    }
    else {
      var node = getLessLoaded(this, ds)

      node[method](query, callback)
    }
  }
}
762111
function RPCify (obj, opts) {
  if (!obj) return null
  if (!(this instanceof RPCify)) return new RPCify(obj, opts)
  opts = opts || {}

  var defaults = {
    skipPrivate: true,
    include: null,
    exclude: [],
    override: {},
    factory: null,
    name: null,
    access: function () { return true }
  }

  if (obj.__hyperpc) {
    this.opts = Object.assign(defaults, obj.__hyperpc, opts)
  } else if (obj.prototype && obj.prototype.__hyperpc) {
    this.opts = Object.assign(defaults, obj.prototype.__hyperpc, opts)
  } else if (!obj.prototype && Object.getPrototypeOf(obj) && Object.getPrototypeOf(obj).__hyperpc) {
    this.opts = Object.assign(defaults, Object.getPrototypeOf(obj).__hyperpc, opts)
  } else {
    this.opts = Object.assign(defaults, opts)
  }

  this.access = this.opts.access
  this.override = this.opts.override
  this.cache = {}

  if (obj.prototype) {
    // 1. Class (prototype)

    if (opts.factory) this.factory = opts.factory
    else this.factory = makeDefaultFactory(obj)

    this.instance = null
    this.name = obj.name
    this.funcs = getAllFuncs(obj.prototype)
  } else {
    // 2. Object instance

    this.factory = null
    this.instance = obj
    this.name = Object.getPrototypeOf(obj).name
    this.funcs = getAllFuncs(obj)
  }

  var out = ['constructor']
  if (this.opts.exclude) out = out.concat(this.opts.exclude)

  this.filteredFuncs = this.funcs.filter(f => {
    if (this.opts.include && this.opts.include.indexOf(f) === -1) return false
    if (out.indexOf(f) !== -1) return false
    if (this.opts.skipPrivate && f.substr(0, 1) === '_') return false
    return true
  })
}
334884
def decorate_class_method(func, classkey=None, skipmain=False):
    
    #import utool as ut
    global __CLASSTYPE_ATTRIBUTES__
    assert classkey is not None, 'must specify classkey'
    #if not (skipmain and ut.get_caller_modname() == '__main__'):
    __CLASSTYPE_ATTRIBUTES__[classkey].append(func)
    return func
34200
def method_wrapper(m):
    """"""

    if m.is_simple:
        def simple_method(self):
            """TODO: no docstring!"""
            return apply_transform(
                self.__service__, m.output_transform,
                grpc_call(self.__service__, m, unwrap(self)))

        return simple_method

    elif m.input_transform is not None:
        def transform_method(self, *args, **kwargs):
            """TODO: no docstring!"""
            request = m.input_transform(self, *args, **kwargs)
            return apply_transform(
                self.__service__, m.output_transform,
                grpc_call(self.__service__, m, request))

        return transform_method

    elif m.static:
        def static_method(cls, *args, **kwargs):
            """TODO: no docstring!"""
            request = make_static_request(m, *args, **kwargs)
            return apply_transform(
                cls.__stub__(__server__), m.output_transform,
                grpc_call(cls.__stub__(__server__), m, request))

        return static_method

    else:
        def request_method(self, *args, **kwargs):
            """TODO: no docstring!"""
            request = make_request(self, m, *args, **kwargs)
            return apply_transform(
                self.__service__, m.output_transform,
                grpc_call(self.__service__, m, request))

        return request_method
287977
def method_missing(method, *args, &block)
      return rpc(method, args.first, args[1]) if function(method)

      super
    end
935356
function async(func)
{
  function wrapper()
  {
    var context = this;
    var args    = arguments;
    process.nextTick(function()
    {
      func.apply(context, args);
    });
  }

  return wrapper;
}
728641
public Function getFunction(String iface, String func) throws RpcException {
        Interface i = interfaces.get(iface);
        if (i == null) {
            String msg = "Interface '" + iface + "' not found";
            throw RpcException.Error.METHOD_NOT_FOUND.exc(msg);
        }

        Function f = i.getFunction(func);
        if (f == null) {
            String msg = "Function '" + iface + "." + func + "' not found";
            throw RpcException.Error.METHOD_NOT_FOUND.exc(msg);
        }

        return f;
    }
232010
function decorateEvents(comp) {
    const prototype = /** @type {!Function} */(comp.constructor).prototype;

    if (prototype.__events) return;

    let events = {};

    if (prototype.events) {
        events = prototype.events;
    }

    Object.getOwnPropertyNames(prototype)
        .map(propertyName => handlerMethodPattern.exec(propertyName))
        .filter(x => x)
        .forEach(([methodName, eventType, eventTarget]) => {
            events[eventType] = events[eventType] || {};

            /** @suppress {checkTypes} */
            events[eventType][eventTarget] = comp[methodName];
        })

    prototype.__events = events;
}
150164
function (method, result) {

      // result should not be undefined
      if (result === undefined) {
        console.warn('JSON-RPC2 response from method ' + methodName + ' should return a result. (JSON-RPC2 spec)')
        result = ''
      }

      var rpcMessage = {
        jsonrpc: '2.0',
        result: result,
        id: id
      }

      callback(rpcMessage)
      responseHasBeenSent = true

    }
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
943485
function methodCall(method, args, callback) {
      this.debug('methodCall', method);
      var self = this;

      /**
       * Handle RPC Method Callback.
       *
       * @param {Error} error
       * @param {string} response
       * @returns {*}
       */
      function callbackWrapper(error, response) {
        self.debug('methodCall->callbackWrapper', error, response);
        // TODO: error should be customized to handle more error types
        if (error /*&& error.code === "ENOTFOUND" && error.syscall === "getaddrinfo"*/) {
          error.message = "Unable to connect to WordPress.";
          return callback.call(self, error);
        }

        // Parse Response.
        if (_.isString(response) && self.common.is_numeric(response)) {
          response = parseInt(response);
        }
        callback.call(self, error, response);
      }

      this.__client.rpc.methodCall(
        method,
        args || [],
        callbackWrapper
      );

      // @chainable
      return this;
    }