MCPcopy Index your code
hub / github.com/apache/dubbo-python2 / call

Method call

dubbo/client.py:44–87  ·  view source on GitHub ↗

执行远程调用 :param method: 远程调用的方法名 :param args: 方法参数 1. 对于没有参数的方法,此参数不填; 2. 对于只有一个参数的方法,直接填入该参数; 3. 对于有多个参数的方法,传入一个包含了所有参数的列表; 4. 当前方法参数支持以下类型: * bool

(self, method, args=(), timeout=None)

Source from the content-addressed store, hash-verified

42 self.__host = host
43
44 def call(self, method, args=(), timeout=None):
45 """
46 执行远程调用
47 :param method: 远程调用的方法名
48 :param args: 方法参数
49 1. 对于没有参数的方法,此参数不填;
50 2. 对于只有一个参数的方法,直接填入该参数;
51 3. 对于有多个参数的方法,传入一个包含了所有参数的列表;
52 4. 当前方法参数支持以下类型:
53 * bool
54 * int
55 * long
56 * float
57 * double
58 * java.lang.String
59 * java.lang.Object
60 :param timeout: 请求超时时间(秒),不设置则不会超时
61 :return:
62 """
63 if not isinstance(args, (list, tuple)):
64 args = [args]
65
66 if self.__zk_register: # 优先从zk中获取provider的host
67 host = self.__zk_register.get_provider_host(self.__interface)
68 else:
69 host = self.__host
70 # logger.debug('get host {}'.format(host))
71
72 request_param = {
73 'dubbo_version': self.__dubbo_version,
74 'version': self.__version,
75 'path': self.__interface,
76 'method': method,
77 'arguments': args
78 }
79
80 logger.debug('Start request, host={}, params={}'.format(host, request_param))
81 start_time = time.time()
82 result = connection_pool.get(host, request_param, timeout)
83 cost_time = int((time.time() - start_time) * 1000)
84 logger.debug('Finish request, host={}, params={}'.format(host, request_param))
85 logger.debug('Request invoked, host={}, params={}, result={}, cost={}ms, timeout={}s'.format(
86 host, request_param, result, cost_time, timeout))
87 return result
88
89
90class ZkRegister(object):

Callers 10

test_auto_ruleMethod · 0.95
test_arrayMethod · 0.95
test_pcMethod · 0.95
test_pc_es_centerMethod · 0.95
test_run_defaultMethod · 0.95
testMethod · 0.80
_run_numMethod · 0.80
test_performanceMethod · 0.80
test_objectMethod · 0.80
runFunction · 0.80

Calls 3

get_provider_hostMethod · 0.80
formatMethod · 0.80
getMethod · 0.80

Tested by 10

test_auto_ruleMethod · 0.76
test_arrayMethod · 0.76
test_pcMethod · 0.76
test_pc_es_centerMethod · 0.76
test_run_defaultMethod · 0.76
testMethod · 0.64
_run_numMethod · 0.64
test_performanceMethod · 0.64
test_objectMethod · 0.64
runFunction · 0.64