HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
transport.ConnectionBuilder.ConnectionBuilder Class Reference

The builder is used to encapsulation routine of creation various type of connections. More...

Inheritance diagram for transport.ConnectionBuilder.ConnectionBuilder:
Collaboration diagram for transport.ConnectionBuilder.ConnectionBuilder:

Public Member Functions

def __init__ (self, id_generator)
 constructor More...
 
def build (self, connect_type, connect_params, endPointType=consts.CLIENT_CONNECT)
 build a connection More...
 

Public Attributes

 zmq_context
 
 zmq_poller
 
 id_generator
 
 builders
 

Private Member Functions

def __admin_connection (self, connect_params, endPointType)
 helper function More...
 
def __data_connection (self, connect_params, endPointType)
 helper function More...
 

Detailed Description

The builder is used to encapsulation routine of creation various type of connections.

Factory is used to create various connection objects

Definition at line 21 of file ConnectionBuilder.py.

Constructor & Destructor Documentation

◆ __init__()

def transport.ConnectionBuilder.ConnectionBuilder.__init__ (   self,
  id_generator 
)

constructor

Init global variable

Parameters
id_generatoran instance of IDGenerator object
Init global variable

Definition at line 30 of file ConnectionBuilder.py.

30  def __init__(self, id_generator):
31  '''
32  Init global variable
33  '''
34  self.zmq_context = zmq.Context() # pylint: disable=E1101
35  self.zmq_poller = zmq.Poller() # pylint: disable-msg=E1101
36  self.id_generator = id_generator
37  self.builders = dict({consts.ADMIN_CONNECT_TYPE : self.__admin_connection,
38  consts.DATA_CONNECT_TYPE : self.__data_connection})
39 
40 
def __init__(self)
constructor
Definition: UIDGenerator.py:19

Member Function Documentation

◆ __admin_connection()

def transport.ConnectionBuilder.ConnectionBuilder.__admin_connection (   self,
  connect_params,
  endPointType 
)
private

helper function

is used for create admin connection type

Parameters
connect_paramsan instance of ConnectionParams
endpointTypetype of endpoint (client or server) return zmq.Socket

Definition at line 59 of file ConnectionBuilder.py.

59  def __admin_connection(self, connect_params, endPointType):
60  sock = self.__data_connection(connect_params, endPointType)
61  #@todo need set extra params
62  return sock
63 
64 
Here is the call graph for this function:

◆ __data_connection()

def transport.ConnectionBuilder.ConnectionBuilder.__data_connection (   self,
  connect_params,
  endPointType 
)
private

helper function

is used for create data connection type

Parameters
connect_paramsan instance of ConnectionParams
endpointTypetype of endpoint (client or server) return zmq.Socket

Definition at line 71 of file ConnectionBuilder.py.

71  def __data_connection(self, connect_params, endPointType):
72  sock = None
73  addr = "tcp://" + connect_params.host + ":" + str(connect_params.port)
74  if endPointType == consts.CLIENT_CONNECT:
75  sock = self.zmq_context.socket(zmq.DEALER) # pylint: disable=E0602,E1101
76  sock.setsockopt(zmq.IDENTITY, self.id_generator.get_connection_uid()) # pylint: disable=E0602,E1101
77  sock.connect(addr)
78 
79  if endPointType == consts.SERVER_CONNECT:
80  sock = self.zmq_context.socket(zmq.ROUTER) # pylint: disable=E0602,E1101
81  sock.bind(addr)
82 
83  return sock
84 
Here is the caller graph for this function:

◆ build()

def transport.ConnectionBuilder.ConnectionBuilder.build (   self,
  connect_type,
  connect_params,
  endPointType = consts.CLIENT_CONNECT 
)

build a connection

Parameters
connect_typetype of connection(DATA_CONNECT_TYPE or ADMIN_CONNECT_TYPE)
connect_paramsan instance of ConnectionParams
endpointTypetype of endpoint (client or server)
Returns
Connection

Definition at line 48 of file ConnectionBuilder.py.

48  def build(self, connect_type, connect_params, endPointType=consts.CLIENT_CONNECT):
49  sock = self.builders[connect_type](connect_params, endPointType)
50  return Connection(sock, self.zmq_poller, endPointType)
51 
52 

Member Data Documentation

◆ builders

transport.ConnectionBuilder.ConnectionBuilder.builders

Definition at line 37 of file ConnectionBuilder.py.

◆ id_generator

transport.ConnectionBuilder.ConnectionBuilder.id_generator

Definition at line 36 of file ConnectionBuilder.py.

◆ zmq_context

transport.ConnectionBuilder.ConnectionBuilder.zmq_context

Definition at line 34 of file ConnectionBuilder.py.

◆ zmq_poller

transport.ConnectionBuilder.ConnectionBuilder.zmq_poller

Definition at line 35 of file ConnectionBuilder.py.


The documentation for this class was generated from the following file: