RabbitMQ Module

class amqp.rabbitmq.rabbit_mq_client.RabbitMQClient(configuration, router)[source]

Bases: object

PREFETCH_COUNT = 1
DLQ_ARGS = {'x-dead-letter-exchange': 'DLX'}
__init__(configuration, router)[source]
async init(loop)[source]
Return type:

AbstractRobustExchange

cleanup()[source]
async register_inbound_routes(route_mapping, callback)[source]

Register inbound routes for the AMQ adapter. The route mapping is a comma-separated string that contains list of routes. A route is the mapping of domain and path to the exchange and queue name. This method declare (and thus create) the queue and exchange, bind them together using the regex-like routing expression given in the route. After this the Service is listening on (consuming from) the queue for incoming messages.

Parameters:

route_mapping (str)

async register_data_reply_callback(rpc_callback)[source]
async setup_amq_channel(loop)[source]

Set up the RabbitMQ connection :return: nothing, it applies changes to instance variables

async send_message(message)[source]

The API routine that sends a datagram message (DataMessage) to the destination. The Destination is determined from the DataMessage metadata section, using domain and path as key. :param message: message to send :return: nothing (void) as submitting message to RabbitMQ exchange does not return anything

meaningful. There will be asynch ACK later that will confirm the message was sent to RMQ.

Parameters:

message (DataMessage)

async request_routes()[source]
find_route(domain, path)[source]
Parameters:
  • domain (str)

  • path (str)

Return type:

AMQRoute

exception amqp.rabbitmq.user_management_service_client.UserManagementServiceException(exception_type, message, additional_info=None)[source]

Bases: Exception

Exception raised for errors in the User Management Service.

Parameters:
  • exception_type (str)

  • message (str)

  • additional_info (Dict[str, Any])

__init__(exception_type, message, additional_info=None)[source]
Parameters:
  • exception_type (str)

  • message (str)

  • additional_info (Dict[str, Any])

class amqp.rabbitmq.user_management_service_client.UserManagementServiceClient(configuration, loop=None)[source]

Bases: object

Client for the User Management Service that communicates over RabbitMQ. Supports operations for token, user, group, tenant, and permission services.

Parameters:
EXCHANGE_NAME = 'cleverthis.clevermicro.auth.endpoints'
TOKEN_SERVICE = 'token-service-v1'
USER_SERVICE = 'user-service-v1'
GROUP_SERVICE = 'group-service-v1'
TENANT_SERVICE = 'tenant-service-v1'
PERMISSION_SERVICE = 'permission-service-v1'
RESPONSE_QUEUE_NAME = 'user-management-service-cleverswarm'
__init__(configuration, loop=None)[source]

Initialize the User Management Service client.

Parameters:
  • configuration (AMQConfiguration) – AMQ configuration

  • loop (AbstractEventLoop) – Event loop to use (optional)

async initialize()[source]

Initialize the RabbitMQ connection and set up the exchange and response queue.

Return type:

None

async close()[source]

Close the RabbitMQ connection.

Return type:

None

async call_service(service, method, args=None)[source]

Call a method on a User Management Service.

Parameters:
  • service (str) – Service routing key (e.g., ‘token-service-v1’)

  • method (str) – Method name to call

  • args (Dict[str, Any]) – Method arguments

Returns:

Response data

Raises:

UserManagementServiceException – If the service returns an error

Return type:

Dict[str, Any]

async validate_token(token)[source]

Validate a JWT token.

Parameters:

token (str) – JWT token to validate

Returns:

Token information

Return type:

Dict[str, Any]

async query_user_by_id(user_id)[source]

Query user information by user ID.

Parameters:

user_id (str) – User ID

Returns:

User information

Return type:

Dict[str, Any]

async list_users_in_group(group_id)[source]

List users in a group.

Parameters:

group_id (str) – Group ID

Returns:

List of users

Return type:

List[Dict[str, Any]]