【Firefly API 新版文檔】Package Distributed

 

package distributed這個包中主要封裝了各個服務進程間進行通訊的方法。node子節點域root根節點進程中的接口調用返回的都是延遲對象。關於延遲對象的使用,詳見twisted中Deferred對象。
calss Child child對象對應的是鏈接到本服務進程的某個服務進程對象。稱爲子節點對象。
getName獲取子節點的名稱
  1. type method
  2. //cwd firefly/ distributed / child.py
  3. Params getName()
  4. 返回節點的名稱
複製代碼
setTransport設置子節點的通道
  1. type method
  2. //cwd firefly/ distributed / child.py
  3. Params setTransport(transport)
複製代碼
transport代理通道的實例 instance型
callbackChild回調子節點的接口
  1. type method
  2. //cwd firefly/ distributed / child.py
  3. Params allbackChild(*args,**kw)
複製代碼
將參數*args,**kw傳入 callChild 方法中,返回的是等待 callChild 返回結果的延遲對象
    
class ChildsManager    子節點管理基類
getChildById根據節點id獲取節點實例''
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params getChildById(childId)
複製代碼
childId 節點id int型
返回節點實例

getChildByName根據節點的名稱獲取節點實例
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params getChildByName(childname)
複製代碼
childname 節點名稱 str型
返回節點實例
addChild添加一個子節點
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params addChild(child)
複製代碼
child 節點實例 instance型
將節點添加到管理器中,格式爲{節點id:節點實例},若是節點已存在,返回文字說明
dropChild刪除一個節點
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params dropChild(child)
複製代碼
child 節點實例 instance型
將節點從管理器中刪除

dropChildByID

經過節點id刪除一個節點
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params dropChildByID(childId)
複製代碼
childId 節點id int型
經過節點id,在節點管理器中刪除該節點
callChild調用子節點的接口
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params callChild(childId,*args,**kw)
複製代碼
childId 子節點id
經過子節點id獲取子節點實例,調用子節點接口,返回的是延遲對象。

callChildByName經過節點名稱調用子節點的接口
  1. type method
  2. //cwd firefly/ distributed / manager.py
  3. Params callChildByName(childname,*args,**kw)
複製代碼
Childname  子節點名稱
經過子節點名稱獲取子節點實例,調用子節點接口,返回的是延遲對象。

class RemoteObject遠程調用對象,子節點服務進程中實現。能夠經過這對象去調用root節點的進程中的接口方法。
setName設置節點的名稱
  1. type method
  2. //cwd firefly/ distributed / node.py
複製代碼
Params setName(name)
name 節點名稱 str型
將節點名稱設置爲name
 
getName獲取節點的名稱
  1. type method
  2. //cwd firefly/ distributed / node.py
  3. Params getName()
複製代碼
返回節點名稱的字符串
connect初始化遠程調用對象,鏈接root節點。
  1. type method
  2. //cwd firefly/ distributed / node.py
  3. Params connect(addr)
複製代碼
Addr 遠程鏈接的地址 tuple型 (主機名,端口號) 例如:(‘localhost’,8888)
addServiceChannel設置服務對象,這個服務對象中管理了可供root節點調用的接口方法。
  1. type method
  2. //cwd firefly/ distributed / node.py
  3. Params addServiceChannel(service)
複製代碼
service爲 //cwd firefly/ utils/ services.py 中service類
takeProxy像遠程服務端發送代理通道對象
  1. type method
  2. //cwd firefly/ distributed / node.py
  3. Params takeProxy()
複製代碼
callRemote遠程調用root節點中的接口方法。
  1. type method
  2. //cwd firefly/ distributed / node.py
  3. Params callRemote(commandId,*args,**kw)
複製代碼
commandId 指令號 int型
遠程調用root節點中指令號爲commandId的方法


class ProxyReference    代理通道
addService-----------添加一條服務通道
  1. type method
  2. //cwd firefly/ distributed / reference.py
  3. Params addService(service)
複製代碼
service服務通道實例 instance型

remote_callChild--------------代理髮送數據
  1. type method
  2. //cwd firefly/ distributed / reference.py
  3. Params remote_callChild(command,*arg,**kw)
複製代碼
class PBRootPB 協議,root節點對象。
addServiceChannel設置服務對象,這個服務對象中管理了可供node子節點調用的接口方法。
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params addServiceChannel(service)
複製代碼
service服務對象實例 instance型
remote_takeProxy設置代理通道
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params remote_takeProxy(name,transport)
複製代碼
name 子節點id,同時也是子節點名稱
transport代理通道的實例 instance型
實例化child節點,將child節點添加到節點管理器中,設置節點代理通道爲transport
remote_callTarget遠程調用方法
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params remote_callTarget(command,*args,**kw)
複製代碼
command指令號 int型
遠程調用root節點中指令號爲command的方法
dropChild刪除子節點記錄
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params dropChild(*args,**kw)
複製代碼
從節點管理器中刪除子節點
dropChildByID根據ID刪除子節點記錄
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params dropChildByID(childId)
複製代碼
ChildId 子節點id

callChild調用子節點的接口
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params callChild(key,*args,**kw)
複製代碼
key子節點id
經過子節點id獲取子節點實例,調用子節點接口,返回的是延遲對象。

callChildByName調用子節點的接口
  1. type method
  2. //cwd firefly/ distributed / root.py
  3. Params callChildByName(childname,*args,**kw)
複製代碼
childname子節點名稱經過子節點名稱獲取子節點實例,調用子節點接口,返回的是延遲對象。
相關文章
相關標籤/搜索