日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python迅雷sdk_Python anthunder包_程序模块 - PyPI - Python中文网

發(fā)布時間:2025/3/15 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python迅雷sdk_Python anthunder包_程序模块 - PyPI - Python中文网 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

安敦達(又名沙發(fā)螺栓Python)

anthunder(ant thunder)是一個用python編寫的沙發(fā)螺栓庫。

它支持通過“sofa bolt+protobuf”協(xié)議調(diào)用rpc。

要求python3>=3.4(aio類需要異步支持)

python2.7(支持有限,需要額外的第三方庫)

mosn>=1.3(用于版本>=0.6)

mosn<1.3(用于<0.6版)

路線圖[X]螺栓客戶端(protobuf序列化)

[X]通過Mosn發(fā)現(xiàn)服務(沙發(fā)服務網(wǎng)側(cè)車)

[X]螺栓服務器(protobuf序列化)

[]Hessian2序列化支持

教程

作為客戶(呼叫者)獲取.proto文件

執(zhí)行protoc --python_out=. *.proto編譯protobuf文件,并獲取_pb2.py文件。

導入protobuf類(用_pb2后綴)fromSampleServicePbResult_pb2importSampleServicePbResultfromSampleServicePbRequest_pb2importSampleServicePbRequestfromanthunderimportAioClientspanctx=SpanContext()# generate a new context, an object of mytracer.SpanContext, stores rpc_trace_context.# spanctx = ctx # or transfered from upstream rpcclient=AioClient(my_app_name)# my_app_name will be send to sidecar as caller name.# will create a thread, and send heartbeat to mesh every 30sinterface='com.alipay.rpc.common.service.facade.pb.SampleServicePb:1.0'# Subscribe interfaceclient.subscribe(interface)# Call synchronouslycontent=client.invoke_sync(interface,"hello",SampleServicePbRequest(name=some_name).SerializeToString(),timeout_ms=500,spanctx=spanctx)result=SampleServicePbResult()result.ParseFromString(content)# Call asynchronouslydefclient_callback(resp):# callback function, accepts bytes as the only argument,# then do deserialize and further processesresult=SampleServicePbResult()result.ParseFromString(content)# do somethingfuture=client.invoke_async(interface,"hello",SampleServicePbRequest(name=some_name).SerializeToString(),spanctx=spanctx,callback=client_callback))

有關(guān)可運行的演示,請參見項目的unittest

作為服務器fromanthunder.listenerimportaio_listenerclassSampleService(object):def__init__(self,ctx):# service must accept one param as spanctx for rpc tracing supportself.ctx=ctxdefhello(self,bs:bytes):obj=SampleServicePbRequest()obj.ParseFromString(bs)print("Processing Request",obj)returnSampleServicePbResult(result=obj.name).SerializeToString()listener=aio_listener.AioListener(('127.0.0.1',12200),"test_app")# register interface and its function, plus its protobuf definition classlistener.handler.register_interface("com.alipay.rpc.common.service.facade.pb.SampleServicePb:1.0",SampleService)# start server in a standalone threadlistener.run_threading()# or start in current threadlistener.run_forever()# publish interfaces to service meshlistener.publish()# shutdown the serverlistener.shutdown()

許可證

版權(quán)所有(c)2018年至今,螞蟻金融服務集團

apache許可證2.0

請參閱許可證文件。

第三方

mysockpool包的一部分使用來自urllib3項目的代碼

根據(jù)麻省理工學院的許可證。請參閱mysockpool包下的origin-license.txt。

發(fā)布歷史記錄

0.5.6(2019-03-15)

錯誤修復修復解析協(xié)議時出現(xiàn)的無限循環(huán)錯誤

0.5.4(2018-11-09)

錯誤修復修復python2.7下的服務器錯誤

0.5.3(2018-08-27)

功能支持AntShareCloud參數(shù)。

0.5.2(2018-09-03)

錯誤修復修復python2.7下的各種錯誤

0.5.1(2018-08-31)

錯誤修復sofa trace rpc id可能包含str.

歡迎加入QQ群-->: 979659372

推薦PyPI第三方庫

總結(jié)

以上是生活随笔為你收集整理的python迅雷sdk_Python anthunder包_程序模块 - PyPI - Python中文网的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。