Skip to content

fireflyAPI distributed API

9miao Mobile Game edited this page Aug 7, 2014 · 1 revision

fireflyAPI- distributed API

package distributed

Distributed mainly encapsulates communication methods among service processes. The call to interface of child nodes and root nodes processes all returns deferred objects. You can read the “Deferred object” part in Twisted about the using of deferred objects.

Class Child

Child object corresponds with a service process object that connects this server process. We call it child node object.

getName

Obtain name of child node
type method
//cwd firefly/ distributed / child.py
Params getName()
Return name of node

setTransport

set child node channel
type method
//cwd firefly/ distributed / child.py
Params setTransport(transport)
Transport: agent channel instance, instance type

callbackChild

Callback the interface of child node
type method
//cwd firefly/ distributed / child.py
Params allbackChild(*args,*kw)
Import parameter args,
to callChild , return the deferred object that waits callchild returning result.

class ChildsManager

Child node management base class

getChildById

Obtain node instance according to node id

type method
//cwd firefly/ distributed / manager.py
Params getChildById(childId)
childId: node id, int type
Return node instance

getChildByName

Obtain node instance according to node name
type method
//cwd firefly/ distributed / manager.py
Params getChildByName(childname)
Return node instance

addChild

Add a child node
type method
//cwd firefly/ distributed / manager.py
Params addChild(child)
Child: node instance, instance type
Add node to manager as { node id: node instance }format, if node is existed, return explanatory note.

dropChild

Delete a node
type method
//cwd firefly/ distributed / manager.py
Params dropChild(child)
Child: node instance, instance type
Delete node from manager

dropChildByID

delete a node according to node ID
type method
//cwd firefly/ distributed / manager.py
Params dropChildByID(childId)

childId: node id, int type
Delete the node in node manager according to the node id

callChild

Call interface of child node
type method
//cwd firefly/ distributed / manager.py
Params callChild(childId,*args,**kw)
childId: child node id
Obtain child node instance according to node id, call the interface of child node ,return the deferred object.

callChildByName

Call interface of child node according to node name
type method
//cwd firefly/ distributed / manager.py
Params callChildByName(childname,*args,**kw)
Childname: child node name
Obtain child node instance according to node name, call the interface of child node ,return the deferred object.

class RemoteObject

Realize remote call object in child node service process. You can call the interface method in root node process via this object.

setName

Set node name
type method
//cwd firefly/ distributed / node.py
Params setName(name)
Name: node name, str type
Set node name as ‘name’

getName

obtain node name
type method
//cwd firefly/ distributed / node.py
Params getName()
Return string of node name

connect

Initialize remote call object and connects root node
type method
//cwd firefly/ distributed / node.py
Params connect(addr)
Addr: remote connection’s address, tuple type. (host name, port number) example: ((‘localhost’,8888)

addServiceChannel

Set service object, this service object manages the interface methods that are available to call by root node.
type method
//cwd firefly/ distributed / node.py
Params addServiceChannel(service)
Service: service class in //cwd firefly/ utils/ services.py

takeProxy

Send agent channel objects to remote server
type method
//cwd firefly/ distributed / node.py
Params takeProxy()

callRemote

Remote call the interface methods in root node
type method
//cwd firefly/ distributed / node.py
Params callRemote(commandId,*args,**kw)
commandId: command number, int type
Remote call the method (command number: commandId) in root node

class ProxyReference

Agent channel
Add a service channel
type method
//cwd firefly/ distributed / reference.py
Params addService(service)
Service: service channel instance, instance type

remote_callChild

Send data in an agent way
type method
//cwd firefly/ distributed / reference.py
Params remote_callChild(command,*arg,**kw)

class PBRoot

PB: protocol, root node object.

addServiceChannel

Set service object, this service object manages the interface methods that are available to call by root node.

type method
//cwd firefly/ distributed / root.py
Params addServiceChannel(service)

Service: service object instance, instance type

remote_takeProxy

Set agent channel
type method
//cwd firefly/ distributed / root.py
Params remote_takeProxy(name,transport)
Name: child node name id as well as child node name
Transport: agent channel instance, instance type
Instantiate child node, add child node to node manager and set node agent channel as transport.

remote_callTarget

Remote call methods
type method
//cwd firefly/ distributed / root.py
Params remote_callTarget(command,*args,**kw)
Command: command number, int type
Remote call method (command number: command) in root node

dropChild

Delete child node records
type method
//cwd firefly/ distributed / root.py
Params dropChild(*args,**kw)
Delete child nodes in node manager

dropChildByID

Delete child node records according to ID
type method
//cwd firefly/ distributed / root.py
Params dropChildByID(childId)
ChildId: child node id

callChild

Call the interface of child node
type method
//cwd firefly/ distributed / root.py
Params callChild(key,*args,**kw)
Key: child node id
Obtain child node instance via child node id, call the interface of child node and return deferred objects.

callChildByName

Call the interface of child node
type method
//cwd firefly/ distributed / root.py
Params callChildByName(childname,*args,**kw)
Childname: child node name

Obtain child node instance via child node name, call the interface of child node and return deferred objects.