ReMe/reme_cli/component/client/base_client.py
jinli.yl b9ce64de7f refactor(component): restructure client and component architecture
- Replace ReMeClient with modular client implementations
- Add component registry with type-based registration system
- Introduce BaseClient extending BaseComponent with lifecycle management
- Create HttpClient with environment-based service discovery
- Add constants for default host/port configurations
- Update service info propagation through environment variables
- Restructure imports and exports across component modules
- Add run_coro_safely utility for safe coroutine execution
- Implement component type enumeration for better organization
- Register components with R decorator for automatic discovery
- Add placeholder methods for ReMe core functionalities
- Update command-line entry point to use dynamic client selection
2026-04-14 15:51:07 +08:00

25 lines
736 B
Python

"""Abstract base class for client implementations."""
from abc import abstractmethod
from ..base_component import BaseComponent
from ...enumeration import ComponentEnum
class BaseClient(BaseComponent):
"""Abstract base class for clients that communicate with ReMe services."""
component_type = ComponentEnum.CLIENT
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.client = None
async def _start(self, app_context=None) -> None:
"""Initialize the client."""
async def _close(self) -> None:
"""Close the client."""
@abstractmethod
async def __call__(self, action: str, **kwargs) -> dict:
"""Invoke an action with the given configuration."""