New enterprise feature
This commit is contained in:
@@ -18,6 +18,7 @@ from .suppliers_client import SuppliersServiceClient
|
||||
from .tenant_client import TenantServiceClient
|
||||
from .ai_insights_client import AIInsightsClient
|
||||
from .alerts_client import AlertsServiceClient
|
||||
from .procurement_client import ProcurementServiceClient
|
||||
|
||||
# Import config
|
||||
from shared.config.base import BaseServiceSettings
|
||||
@@ -69,10 +70,10 @@ def get_inventory_client(config: BaseServiceSettings = None, service_name: str =
|
||||
"""Get or create an inventory service client"""
|
||||
if config is None:
|
||||
from app.core.config import settings as config
|
||||
|
||||
|
||||
cache_key = f"inventory_{service_name}"
|
||||
if cache_key not in _client_cache:
|
||||
_client_cache[cache_key] = InventoryServiceClient(config)
|
||||
_client_cache[cache_key] = InventoryServiceClient(config, service_name)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
def get_orders_client(config: BaseServiceSettings = None, service_name: str = "unknown") -> OrdersServiceClient:
|
||||
@@ -89,20 +90,20 @@ def get_production_client(config: BaseServiceSettings = None, service_name: str
|
||||
"""Get or create a production service client"""
|
||||
if config is None:
|
||||
from app.core.config import settings as config
|
||||
|
||||
|
||||
cache_key = f"production_{service_name}"
|
||||
if cache_key not in _client_cache:
|
||||
_client_cache[cache_key] = ProductionServiceClient(config)
|
||||
_client_cache[cache_key] = ProductionServiceClient(config, service_name)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
def get_recipes_client(config: BaseServiceSettings = None, service_name: str = "unknown") -> RecipesServiceClient:
|
||||
"""Get or create a recipes service client"""
|
||||
if config is None:
|
||||
from app.core.config import settings as config
|
||||
|
||||
|
||||
cache_key = f"recipes_{service_name}"
|
||||
if cache_key not in _client_cache:
|
||||
_client_cache[cache_key] = RecipesServiceClient(config)
|
||||
_client_cache[cache_key] = RecipesServiceClient(config, service_name)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
def get_suppliers_client(config: BaseServiceSettings = None, service_name: str = "unknown") -> SuppliersServiceClient:
|
||||
@@ -112,7 +113,7 @@ def get_suppliers_client(config: BaseServiceSettings = None, service_name: str =
|
||||
|
||||
cache_key = f"suppliers_{service_name}"
|
||||
if cache_key not in _client_cache:
|
||||
_client_cache[cache_key] = SuppliersServiceClient(config)
|
||||
_client_cache[cache_key] = SuppliersServiceClient(config, service_name)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
def get_alerts_client(config: BaseServiceSettings = None, service_name: str = "unknown") -> AlertsServiceClient:
|
||||
@@ -125,6 +126,26 @@ def get_alerts_client(config: BaseServiceSettings = None, service_name: str = "u
|
||||
_client_cache[cache_key] = AlertsServiceClient(config, service_name)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
def get_tenant_client(config: BaseServiceSettings = None, service_name: str = "unknown") -> TenantServiceClient:
|
||||
"""Get or create a tenant service client"""
|
||||
if config is None:
|
||||
from app.core.config import settings as config
|
||||
|
||||
cache_key = f"tenant_{service_name}"
|
||||
if cache_key not in _client_cache:
|
||||
_client_cache[cache_key] = TenantServiceClient(config)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
def get_procurement_client(config: BaseServiceSettings = None, service_name: str = "unknown") -> ProcurementServiceClient:
|
||||
"""Get or create a procurement service client"""
|
||||
if config is None:
|
||||
from app.core.config import settings as config
|
||||
|
||||
cache_key = f"procurement_{service_name}"
|
||||
if cache_key not in _client_cache:
|
||||
_client_cache[cache_key] = ProcurementServiceClient(config, service_name)
|
||||
return _client_cache[cache_key]
|
||||
|
||||
|
||||
class ServiceClients:
|
||||
"""Convenient wrapper for all service clients"""
|
||||
@@ -247,5 +268,10 @@ __all__ = [
|
||||
'get_recipes_client',
|
||||
'get_suppliers_client',
|
||||
'get_alerts_client',
|
||||
'get_service_clients'
|
||||
]
|
||||
'get_tenant_client',
|
||||
'get_procurement_client',
|
||||
'get_service_clients',
|
||||
'create_forecast_client'
|
||||
]
|
||||
# Backward compatibility aliases
|
||||
create_forecast_client = get_forecast_client
|
||||
|
||||
Reference in New Issue
Block a user