ibmfl.connection

FL Connection

class ibmfl.connection.connection.FLConnection[source]
RECEIVER_STATUS = None

Initialze sender and receiver

Parameters

kwargs – Dictionary of arguments required by each type of sender implementation

__weakref__

list of weak references to the object (if defined)

Flask Connection

Connection class which uses flask and request libraries to create a server client combo.

class ibmfl.connection.flask_connection.FlaskConnection(config)[source]
__init__(config)[source]

Initialized the connection object and validates the config provided to this connection instance

Parameters

config (dict) – Dictionary of configuration provided to connection

get_connection_config()[source]

Provide a connection information such that a node can communicate to other nodes on how to communicate with it.

Returns

settings

Return type

dict

get_ssl_config(config)[source]

Loads tls config from connection config. Returns None when no config is provided :param config: Configuraiton sent from application :type config: dict

Returns

ssl config

Return type

dict

initialize(**kwargs)[source]

Initialize receiver and sender

initialize_receiver(router=None)[source]

Initialize flask server using the settings and handler.

Parameters

router (Router) – Router object describing the routes for each request which are passed down to PH

initialize_sender()[source]

Initialize simple http client using the settings provided during connection creation

process_config(config)[source]

Validates the configuration provided to flask connection and returns a settings dictionary with all the information extracted from config

Parameters

config (dict) – configuraiton sent from application

Returns

settings

Return type

dict

start()[source]

starts the receiver in a new thread

start_receiver()[source]

starts the receiver in a new thread

stop()[source]

Stop and cleanup the connection

PubSub Connection

class ibmfl.connection.rabbitmq_connection.RabbitMQConnection ( config ) [source]

Class for PubSub connection

__init__ ( config ) [source]

Initializes the connection object and validates the config provided to this connection instance

Parameters
  • config (dict) – dictionary of configuration provided to connection

initialize ( **kwargs ) [source]

Initialize receiver and sender

initialize_receiver ( router=None ) [source]

Initialize server using the settings and handler

Parameters
  • router (Router) – Router object describing the routes for each request which are passed down to PH

initialize_sender ( ) [source]

Initialize a sender object using the settings provided during connection creation

process_config ( config ) [source]

Validates the configuration provided to RabbitMQ connection and returns a settings dictionary with all the information extracted from config

Parameters
  • config (dict) – configuration sent from application

Returns

settings

Return type

dict

get_connection_config ( ) [source]

Provide a connection information such that a node can communicate to other nodes on how to communicate with it

start ( ) [source]

Starts the receiver in a new thread

start_receiver ( ) [source]

Starts the receiver in a new thread

stop ( ) [source]

Stop and cleanup the connection

class ibmfl.connection.rabbitmq_connection.RabbitMQReceiver ( router, comms ) [source]

Class for RabbitMQ Receiver

__init__ ( router, comms ) [source]

Initializes server instance with reference to Router

Parameters
  • router (Router) – Router object describing the routes for each request which are passed down to PH

  • comms (list) – A list of RabbitMQ connection objects

static set_stoppable ( ) [source]

Create and set 'stop_receiver' global variable

start ( ) [source]

Start a new thread for the party

receive_message ( ) [source]

Receive function of the receiver

class ibmfl.connection.rabbitmq_connection.RabbitMQSender ( comms, settings, ) [source]

Class for RabbitMQ Sender

__init__ ( comms, settings ) [source]

Initializes the connection with settings object which is passed from Aggregator/party

Parameters
  • comms (list) – A list of RabbitMQ connection objects

  • settings (dict) – dictionary with connection details

initialize ( ) [source]

Does all the setups required for the sender

send_message ( destination, message ) [source]

Used for sending all the requests with a single message

Parameters
  • destination (str) – information about the destination to which message should be forwarded, not used in RabbitMQ connection

  • message (Message) – message object constructed by aggregator/party

Returns

response object

Return type

Message

send_messages ( destination, messages ) [source]

Used for sending all the requests with a multiple messages from the aggregator to all parties

Parameters
  • destination (str) – information about the destination to which message should be forwarded, not used in RabbitMQ connection

  • messages (Message) – message object constructed by aggregator/party

Returns

response object

Return type

Message

Router

Module acting as a bridge between Server and ProtocolHandler Routes for all the requests received by the server are redirected to designated handler in PH using routers

class ibmfl.connection.router_handler.Router[source]

Container used to add and match a group of routes.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

add_route(path, handler)[source]

Add path, handler combination in a dictionary. Throws DuplicateRouteException when route is repeated

Parameters
  • path – special pre defined /assigned identifier which will be used by the client to reach specific handler in the PH

  • handler – method which needs to handle the request carrying the special identifier

Raises

DuplicateRouteException – exception is raised when path is added multiple times

add_routes(routes)[source]

Add multiple path, handler combinations in routes dictionary. Throws DuplicateRouteException when route is repeated

Parameters

routes – list of path, handler combination

Raises

DuplicateRouteException – exception is raised when path is added multiple times

get_handler(request_path)[source]

Gets handler for path specified in the request

Parameters

request_path – path or identifier provided in the request message

Returns

a handler which was assigned when Router object was created