from contextlib import asynccontextmanager import config from extensions.shaanxi.client import GatewayClient from extensions.shaanxi.settings import GatewaySettings def enabled(): return config.get_bool("SHANXI_GATEWAY_ENABLED", False) def validate_config(): GatewaySettings.from_config() @asynccontextmanager async def gateway_service(dependencies): client = GatewayClient(GatewaySettings.from_config()) try: yield client finally: await client.close() def setup(registry): registry.register_service("shaanxi_gateway", gateway_service)