feat/#61 - add client code for User Managemengt Service
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Dict
|
||||
|
||||
from amqp.config.amq_configuration import AMQConfiguration
|
||||
from amqp.rabbitmq.user_management_service_client import (
|
||||
UserManagementServiceClient,
|
||||
UserManagementServiceException
|
||||
UserManagementServiceException,
|
||||
)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ async def get_user_info_from_token(
|
||||
raise UserManagementServiceException(
|
||||
"cleverthis.clevermicro.auth.invalid_token",
|
||||
"Token does not contain user ID (sub claim)",
|
||||
{}
|
||||
{},
|
||||
)
|
||||
|
||||
# Query user information
|
||||
@@ -57,7 +57,7 @@ async def get_user_info_from_token(
|
||||
|
||||
async def main():
|
||||
# Initialize configuration
|
||||
config = AMQConfiguration()
|
||||
config = AMQConfiguration("")
|
||||
|
||||
# Create client
|
||||
client = UserManagementServiceClient(config)
|
||||
|
||||
@@ -160,6 +160,12 @@ class DataMessageHandler:
|
||||
async def reconstitute_data_message(
|
||||
self, message: AbstractIncomingMessage
|
||||
) -> DataMessage | None:
|
||||
"""
|
||||
DataMessage may be serialized as string in separate queue (addressing == 1) or be a MultiPart message with
|
||||
files streamed over individual queues, one per file.
|
||||
This function uses 'addressing' mode from message headers to determine how to deserialize (reconstitute)
|
||||
the original message.
|
||||
"""
|
||||
amq_message: DataMessage | None = None
|
||||
delivery_tag = message.delivery_tag
|
||||
addressing: int = message.headers.get("clevermicro.addressing", 0)
|
||||
@@ -246,8 +252,8 @@ class DataMessageHandler:
|
||||
|
||||
async def reply_received_callback(self, message: AbstractIncomingMessage):
|
||||
"""
|
||||
The reply for DataMessage that we sent out earlier - must match the received response with
|
||||
the original request and respond to the caller.
|
||||
The handler for reply for DataMessage that we sent out earlier -
|
||||
the code matches the received response with the original request and passes the response to the caller.
|
||||
:param message:
|
||||
:return:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user