Commit 1e204039 authored by litaolemo's avatar litaolemo

update

parent 8d30e4c7
......@@ -6,7 +6,38 @@
import requests
import typing
from crawler.crawler_sys.utils.rpc import rpc_invoker,get_rpc_invoker
import asyncio
from gm_client.rpc import create_default_invoker
from gm_client.rpc.internal.context import ClientContext
async def main():
ctx = ClientContext(timeout=3, metadata={})
ctx.session_key = "xxxxxx"
ctx.device_id = "device-123456789"
ctx.user_id = 123456
invoker = create_default_invoker(debug=True).with_config(dump_curl=True)
res = await invoker["diagnosis/test"](ctx, echo="hello")
print(res.success)
print(res.unwrap())
print(res)
# metadata = Metadata(
# session_key=
# )
# GM-Meta-xxxxxxx
results = await asyncio.gather(*(
invoker["diagnosis/test"](ctx, echo=str(i))
for i in range(3)
))
print(results)
"""
https://www.yuque.com/docs/share/f4abe44b-6593-46b4-b280-5c87e4db2c85?#
rpc: cims/question/batch_create 创建问题
......@@ -43,8 +74,12 @@ def post_data(data_dict:typing.Dict,rpc_type:str) -> typing.Dict:
data = {
'requests': '[{"params": {"replies": [{%s}]}, "method": "%s, "timeout": 120}]' % (str(data_dict),rpc_type)
}
rpc_client = get_rpc_invoker()
res = rpc_client[rpc_type]().unwrap()
invoker = create_default_invoker(debug=True).with_config(dump_curl=True)
res = await invoker[rpc_type](**data_dict)
print(res.success)
print(res.unwrap())
print(res)
return res
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment