mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
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.
68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
|
|
from dataclasses import dataclass, field
|
|
|
|
from ..core.topic import queue
|
|
from ..core.primitives import Error
|
|
|
|
############################################################################
|
|
|
|
# Flow service:
|
|
# list_blueprints() -> (blueprintname[])
|
|
# get_blueprint(blueprintname) -> (blueprint)
|
|
# put_blueprint(blueprint) -> (blueprint)
|
|
# delete_blueprint(blueprintname) -> ()
|
|
#
|
|
# list_flows() -> (flowid[])
|
|
# get_flow(flowid) -> (flow)
|
|
# start_flow(flowid, blueprintname) -> ()
|
|
# stop_flow(flowid) -> ()
|
|
|
|
# Prompt services, abstract the prompt generation
|
|
@dataclass
|
|
class FlowRequest:
|
|
operation: str = "" # list-blueprints, get-blueprint, put-blueprint, delete-blueprint
|
|
# list-flows, get-flow, start-flow, stop-flow
|
|
|
|
# get_blueprint, put_blueprint, delete_blueprint, start_flow
|
|
blueprint_name: str = ""
|
|
|
|
# put_blueprint
|
|
blueprint_definition: str = ""
|
|
|
|
# start_flow
|
|
description: str = ""
|
|
|
|
# get_flow, start_flow, stop_flow
|
|
flow_id: str = ""
|
|
|
|
# start_flow - optional parameters for flow customization
|
|
parameters: dict[str, str] = field(default_factory=dict)
|
|
|
|
@dataclass
|
|
class FlowResponse:
|
|
# list_blueprints
|
|
blueprint_names: list[str] = field(default_factory=list)
|
|
|
|
# list_flows
|
|
flow_ids: list[str] = field(default_factory=list)
|
|
|
|
# get_blueprint
|
|
blueprint_definition: str = ""
|
|
|
|
# get_flow
|
|
flow: str = ""
|
|
|
|
# get_flow
|
|
description: str = ""
|
|
|
|
# get_flow - parameters used when flow was started
|
|
parameters: dict[str, str] = field(default_factory=dict)
|
|
|
|
# Everything
|
|
error: Error | None = None
|
|
|
|
flow_request_queue = queue('flow', cls='request')
|
|
flow_response_queue = queue('flow', cls='response')
|
|
|
|
############################################################################
|
|
|