eii package¶
Submodules¶
Custom exceptions used in the Python module
- 
exception 
eii.exc.Disconnected¶ Bases:
ExceptionError raised when a receive context has been disconnected.
- 
exception 
eii.exc.MessageBusAuthenticationFailed¶ Bases:
ExceptionError raised when the message bus authentication for a receive context fails.
- 
exception 
eii.exc.MessageBusError¶ Bases:
ExceptionGeneric exception used when an issue occurs in a message bus method
- 
exception 
eii.exc.ReceiveTimeout¶ Bases:
ExceptionException raised when a timeout has occurred while attempting to receive a message.
EII Message Envelope utility functions
- 
class 
eii.msg_envelope.MsgEnvelope(meta_data=None, blob=None, name=None)¶ Bases:
objectEII Message Envelope
- 
get_blob()¶ Get the blob data in the message envelope.
- Returns
 Blob data in the message if any exists
- Return type
 Union[None, bytes]
- 
get_meta_data()¶ Get the meta-data in the message envelope if any exists.
- Returns
 Meta-data in the message envelope
- Return type
 Union[None, dict]
- 
get_name()¶ Get the topic string or service name in the message envelope.
Note
This will only be assigned if the MsgEnvelope was received over the message bus.
- Returns
 Topic string or service name, will be None if not set
- Return type
 Union[None, str]
- 
 
EII Message Bus Python mapping
- 
class 
eii.msgbus.MsgbusContext¶ Bases:
objectEII Message Bus context object
- 
get_service()¶ Create a new service context for issuing requests to a service.
Note that this method will expect to find the configuration attributes needed to communicate with the specified service in the configuration given to the constructor.
- Parameters
 service_name – Name of the service
- Type
 str
- Returns
 Service object
- Return type
 
- 
new_publisher()¶ Create a new publisher object.
- Parameters
 topic – Publisher’s topic
- Type
 str
- Returns
 Publisher object
- Return type
 
- 
new_service()¶ Create a new service context for receiving requests.
Note that this method will expect to find the configuration attributes needed to communicate with the specified service in the configuration given to the constructor.
- Parameters
 service_name – Name of the service
- Type
 str
- Returns
 Service object
- Return type
 
- 
new_subscriber()¶ Create a new subscriber object.
- Parameters
 topic – Topic to subscribe to
- Type
 str
- Returns
 Subscriber object
- Return type
 
- 
 
EII Message Bus Publisher wrapper object
- 
class 
eii.publisher.Publisher¶ Bases:
objectEII Message Bus Publisher object
- 
close()¶ Close the publisher.
This MUST be called before the program exists. If it is not your program may hang.
Note that this method is not thread-safe.
- 
publish()¶ Publish message on the publisher object.
The message object passed to this method can be either a Python bytes object or a Python dictionary. When a bytes object is given to be published, then this method will construct a message envelope for a blob. If a dictionary is given, then a JSON message envelope will be constructed and published.
- Parameters
 message – Message to publish
- Type
 bytes or dict
- 
 
EII Message Bus Python receive context wrapper
- 
class 
eii.receive_context.ReceiveContext¶ Bases:
objectEII Message Bus receive context wrapper object
- 
close()¶ Close the receive context.
This MUST be called before the program exists. If it is not your program may hang.
Note that this method is not thread-safe.
- 
recv()¶ Receive a message on the message bus for the given receive context. Note that the receive context can be a Subscriber or a Service object.
Additionally, if the timeout is set to -1, then this method will operate based on whether blocking is set to True or False (i.e. block or do not block). However, it the timeout is set to anything > -1, then this method will ignore whether blocking is set and use operate on a timeout.
- Parameters
 blocking – (Optional) Block until message received, or return immediately.
timeout – (Optional) Timeout in milliseconds to receive a message
- Type
 bool
- Type
 int
- Returns
 Received message
- Return type
 dict or bytes
- 
 
EII Message Bus service wrapper object for receiving requests
- 
class 
eii.service.Service¶ Bases:
eii.receive_context.ReceiveContextEII Message Bus service wrapper object for receiving requests
- 
response()¶ Issue a response over the message bus.
- Parameters
 resp – Response data
- Type
 bytes or dict
- 
 
EII Message Bus service wrapper object to issue requests
- 
class 
eii.service_requester.ServiceRequester¶ Bases:
eii.receive_context.ReceiveContextEII Message Bus service wrapper object to issue requests
- 
request()¶ Issue a request to the service.
- Parameters
 request – Request to issue to the service
- Type
 bytes or dict
- 
 
Module contents¶
EII Message Bus