Skip to main content

MQ Connector for Neon Modules

Project description

Neon MQ Connector

The Neon MQ Connector is an MQ interface for microservices.

Configuration

By default, this package will use ovos-config to read default configuration. In general, configuration should be passed to the MQConnector object at init.

Legacy Configuration

A global configuration for the MQ Connector may be specified at ~/.config/neon/mq_config.json. This configuration file may contain the following keys:

  • server: The hostname or IP address of the MQ server to connect to. If left blank, this defaults to "localhost"
  • port: The port used by the MQ server. If left blank, this defaults to 5672
  • users: A mapping of service names to credentials. Note that not all users will have permissions required to access each service.
{
  "server": "localhost",
  "port": 5672,
  "users": {
    "<service_name>": {
      "username": "<username>",
      "password": "<password>"
    }
  }
}

Services

The MQConnector class should be extended by a class providing some specific service. Service classes will specify the following parameters.

  • service_name: Name of the service, used to identify credentials in configuration
  • vhost: Virtual host to connect to; messages are all constrained to this namespace.
  • consumers: Dict of names to ConsumerThread objects. A ConsumerThread will accept a connection to a particular connection, a queue, and a callback_func
    • connection: MQ connection to the vhost specified above.
    • queue: Queue to monitor within the vhost. A vhost may handle multiple queues.
    • callback_func: Function to call when a message arrives in the queue

Callback Functions

A callback function should have the following signature:

def handle_api_input(self,
                     channel: pika.channel.Channel,
                     method: pika.spec.Basic.Return,
                     properties: pika.spec.BasicProperties,
                     body: bytes):
    """
        Handles input requests from MQ to Neon API

        :param channel: MQ channel object (pika.channel.Channel)
        :param method: MQ return method (pika.spec.Basic.Return)
        :param properties: MQ properties (pika.spec.BasicProperties)
        :param body: request body (bytes)
    """

Generally, body should be decoded into a dict, and that dict should contain message_id. The message_id should be included in the body of any response to associate the response to the request. A response may be sent via:

 channel.queue_declare(queue='<queue>')

 channel.basic_publish(exchange='',
                       routing_key='<queue>',
                       body=<data>,
                       properties=pika.BasicProperties(expiration='1000')
                       )

Where <queue> is the queue to which the response will be published, and data is a bytes response (generally a base64-encoded dict).

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neon_mq_connector-0.7.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

neon_mq_connector-0.7.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file neon_mq_connector-0.7.1.tar.gz.

File metadata

  • Download URL: neon_mq_connector-0.7.1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for neon_mq_connector-0.7.1.tar.gz
Algorithm Hash digest
SHA256 d2d78183396156a9eed094e4d533fbdd3e5dd06bde2d1ea06732bd217deba724
MD5 f6f923d770bb00084fa4aab8373ab05c
BLAKE2b-256 db3ec1a0047dce99bc95bac46bae459d025e77568d23f56c2395fa59edccfa0a

See more details on using hashes here.

File details

Details for the file neon_mq_connector-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for neon_mq_connector-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a4e9746fad996ec67213dee81ad97262af7d0f50cc3fff9d1ff5e0d5f2e4524
MD5 632aacbd9cd2d021f964c8f0d0404f5f
BLAKE2b-256 ce00913c4a39d984f05f0dfb73b9ed9f17b75fb31e2557ab0b95b6787ef17ace

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page