mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 04:01:02 +02:00
Pull the JSON/Pulsar message translation into a separate module, will be useful for other comms channels
23 lines
574 B
Python
23 lines
574 B
Python
|
|
import base64
|
|
|
|
from ... schema import Document, Metadata
|
|
from ... messaging import TranslatorRegistry
|
|
|
|
from . sender import ServiceSender
|
|
|
|
class DocumentLoad(ServiceSender):
|
|
def __init__(self, pulsar_client, queue):
|
|
|
|
super(DocumentLoad, self).__init__(
|
|
pulsar_client = pulsar_client,
|
|
queue = queue,
|
|
schema = Document,
|
|
)
|
|
|
|
self.translator = TranslatorRegistry.get_request_translator("document")
|
|
|
|
def to_request(self, body):
|
|
print("Document received")
|
|
return self.translator.to_pulsar(body)
|
|
|