Skip to content

polyglot: introduce an abstraction level between the main and brokers' clients #10

@stefanoterna

Description

@stefanoterna

Architecture

Iottly BackendBrokerClients

Each client is basically a wrapper for the specific third party client (sleekxmpp or paho)

Currently we implement:

  • BackendBrokerClientXmpp
  • BackendBrokerClientMqtt

Each broker client is implemented as a class with the same interface:

  • __init__(params): a constructor taking the necessary parameters to let the inner third party client to connect to the broker
  • send_command(cmd): a method to send commands over the protocol

Each BackendBrokerClient

Iottly Polyglot

The Polyglot class abstracts the interaction with each BackendBrokerClient:

  • once instantiated it knows the lisk of currently running BackendBrokerClient
  • it knows how to route the requests to abstract methods towards the corresponding methods of each BackendBrokerClient

Polyglot structure

Globals

A dictionary of currently loaded BackendBrokerClients

Constructor

__init__(backendbrokerclientconf: dict)
Accepts a dict of parameters, grouped in a sub-dict for each of the required BackendBrokerClients:

backendbrokerclientconf = {
  'BackendBrokerClientXmpp': {
  # place here IOTTLY_XMPP_<...> settings needed by BackendBrokerClientXmpp
  },
  'BackendBrokerClientMqtt': {
  # place here IOTTLY_MQTT_<...> settings needed by BackendBrokerClientMqtt
  }
}

The constructor performs the following actions:

  • dinamically loads (with reflection) each module defined in the list of keys of the dict backendbrokerclientconf
  • dinamically instantes (with reflection) each BackendBrokerClient class
  • sets the reference to each instance into the inner dictionary for later retrieval

Methods

  • send_command(cmd, brokerclientname): a method responsible for routing the request to send a command to the proper BackendBrokerClient instance, looking it up in the dictionary by means of the brokerclientname parameter

Main

The Main module must interact with each BackendBrokerClient solely via Polyglot.
It knows:

  • the list of BackendBrokerClient that must be run
  • the dict of conf parameters needed by each BackendBrokerClient to be started
  • the brokerclientname (or protocol) of each device (to ask polyglot to properly route the requests)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions