mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 16:36:21 +02:00
Pub/sub abstraction: decouple from Pulsar (#751)
Remove Pulsar-specific concepts from application code so that the pub/sub backend is swappable via configuration. Rename translators: - to_pulsar/from_pulsar → decode/encode across all translator classes, dispatch handlers, and tests (55+ files) - from_response_with_completion → encode_with_completion - Remove pulsar.schema.Record from translator base class Queue naming (CLASS:TOPICSPACE:TOPIC): - Replace topic() helper with queue() using new format: flow:tg:name, request:tg:name, response:tg:name, state:tg:name - Queue class implies persistence/TTL (no QoS in names) - Update Pulsar backend map_topic() to parse new format - Librarian queues use flow class (persistent, for chunking) - Config push uses state class (persistent, last-value) - Remove 15 dead topic imports from schema files - Update init_trustgraph.py namespace: config → state Confine Pulsar to pulsar_backend.py: - Delete legacy PulsarClient class from pubsub.py - Move add_args to add_pubsub_args() with standalone flag for CLI tools (defaults to localhost) - PulsarBackendConsumer.receive() catches _pulsar.Timeout, raises standard TimeoutError - Remove Pulsar imports from: async_processor, flow_processor, log_level, all 11 client files, 4 storage writers, gateway service, gateway config receiver - Remove log_level/LoggerLevel from client API - Rewrite tg-monitor-prompts to use backend abstraction - Update tg-dump-queues to use add_pubsub_args Also: pubsub-abstraction.md tech spec covering problem statement, design goals, as-is requirements, candidate broker assessment, approach, and implementation order.
This commit is contained in:
parent
dbf8daa74a
commit
4fb0b4d8e8
106 changed files with 1269 additions and 788 deletions
|
|
@ -28,7 +28,7 @@ class TestRequestTranslation:
|
|||
}
|
||||
|
||||
# Translate to Pulsar
|
||||
pulsar_msg = translator.to_pulsar(api_data)
|
||||
pulsar_msg = translator.decode(api_data)
|
||||
|
||||
assert pulsar_msg.operation == "schema-selection"
|
||||
assert pulsar_msg.sample == "test data sample"
|
||||
|
|
@ -46,7 +46,7 @@ class TestRequestTranslation:
|
|||
"options": {"delimiter": ","}
|
||||
}
|
||||
|
||||
pulsar_msg = translator.to_pulsar(api_data)
|
||||
pulsar_msg = translator.decode(api_data)
|
||||
|
||||
assert pulsar_msg.operation == "generate-descriptor"
|
||||
assert pulsar_msg.sample == "csv data"
|
||||
|
|
@ -70,7 +70,7 @@ class TestResponseTranslation:
|
|||
)
|
||||
|
||||
# Translate to API format
|
||||
api_data = translator.from_pulsar(pulsar_response)
|
||||
api_data = translator.encode(pulsar_response)
|
||||
|
||||
assert api_data["operation"] == "schema-selection"
|
||||
assert api_data["schema-matches"] == ["products", "inventory", "catalog"]
|
||||
|
|
@ -86,7 +86,7 @@ class TestResponseTranslation:
|
|||
error=None
|
||||
)
|
||||
|
||||
api_data = translator.from_pulsar(pulsar_response)
|
||||
api_data = translator.encode(pulsar_response)
|
||||
|
||||
assert api_data["operation"] == "schema-selection"
|
||||
assert api_data["schema-matches"] == []
|
||||
|
|
@ -103,7 +103,7 @@ class TestResponseTranslation:
|
|||
error=None
|
||||
)
|
||||
|
||||
api_data = translator.from_pulsar(pulsar_response)
|
||||
api_data = translator.encode(pulsar_response)
|
||||
|
||||
assert api_data["operation"] == "detect-type"
|
||||
assert api_data["detected-type"] == "xml"
|
||||
|
|
@ -123,7 +123,7 @@ class TestResponseTranslation:
|
|||
)
|
||||
)
|
||||
|
||||
api_data = translator.from_pulsar(pulsar_response)
|
||||
api_data = translator.encode(pulsar_response)
|
||||
|
||||
assert api_data["operation"] == "schema-selection"
|
||||
# Error objects are typically handled separately by the gateway
|
||||
|
|
@ -146,7 +146,7 @@ class TestResponseTranslation:
|
|||
error=None
|
||||
)
|
||||
|
||||
api_data = translator.from_pulsar(pulsar_response)
|
||||
api_data = translator.encode(pulsar_response)
|
||||
|
||||
assert api_data["operation"] == "diagnose"
|
||||
assert api_data["detected-type"] == "csv"
|
||||
|
|
@ -165,7 +165,7 @@ class TestResponseTranslation:
|
|||
error=None
|
||||
)
|
||||
|
||||
api_data, is_final = translator.from_response_with_completion(pulsar_response)
|
||||
api_data, is_final = translator.encode_with_completion(pulsar_response)
|
||||
|
||||
assert is_final is True # Structured-diag responses are always final
|
||||
assert api_data["operation"] == "schema-selection"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue