trustgraph/trustgraph-flow/trustgraph/gateway/dispatch/collection_management.py
2025-12-17 21:32:54 +00:00

36 lines
1.5 KiB
Python

from ... schema import CollectionManagementRequest, CollectionManagementResponse
from ... schema import collection_request_queue, collection_response_queue
from ... messaging import TranslatorRegistry
from . requestor import ServiceRequestor
class CollectionManagementRequestor(ServiceRequestor):
def __init__(self, backend, consumer, subscriber, timeout=120,
request_queue=None, response_queue=None):
if request_queue is None:
request_queue = collection_request_queue
if response_queue is None:
response_queue = collection_response_queue
super(CollectionManagementRequestor, self).__init__(
backend=backend,
consumer_name = consumer,
subscription = subscriber,
request_queue=request_queue,
response_queue=response_queue,
request_schema=CollectionManagementRequest,
response_schema=CollectionManagementResponse,
timeout=timeout,
)
self.request_translator = TranslatorRegistry.get_request_translator("collection-management")
self.response_translator = TranslatorRegistry.get_response_translator("collection-management")
def to_request(self, body):
print("REQUEST", body, flush=True)
return self.request_translator.to_pulsar(body)
def from_response(self, message):
print("RESPONSE", message, flush=True)
return self.response_translator.from_response_with_completion(message)