mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-12 08:42:37 +02:00
Replace singleton LibrarianClient with per-flow instances via the new LibrarianSpec, giving each flow its own librarian tied to the workspace-scoped request/response queues from the blueprint. Move all workspace-scoped services (config, flow, librarian, knowledge) from a single base-queue response producer to per-workspace response producers created alongside the existing per-workspace request consumers. Update the gateway dispatcher and bootstrapper flow client to subscribe to the matching workspace-scoped response queues. Fix WorkspaceInit to register workspaces through the IAM create-workspace API so they appear in __workspaces__ and are visible to the gateway. Simplify the bootstrapper gate to only check config-svc reachability. Updated tests accordingly.
31 lines
998 B
Python
31 lines
998 B
Python
from __future__ import annotations
|
|
|
|
import uuid
|
|
from typing import Any
|
|
|
|
from . spec import Spec
|
|
from . librarian_client import LibrarianClient
|
|
|
|
|
|
class LibrarianSpec(Spec):
|
|
def __init__(self, request_name="librarian-request",
|
|
response_name="librarian-response"):
|
|
self.request_name = request_name
|
|
self.response_name = response_name
|
|
|
|
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
|
|
|
client = LibrarianClient(
|
|
id=flow.id,
|
|
backend=processor.pubsub,
|
|
taskgroup=processor.taskgroup,
|
|
librarian_request_queue=definition["topics"][self.request_name],
|
|
librarian_response_queue=definition["topics"][self.response_name],
|
|
librarian_subscriber=(
|
|
processor.id + "--" + flow.workspace + "--" +
|
|
flow.name + "--librarian--" + str(uuid.uuid4())
|
|
),
|
|
flow_name=flow.name,
|
|
)
|
|
|
|
flow.librarian = client
|