Service
public interface Service
源码Source
io/agentscope/runtime/engine/services/Service.java:40–58服务的抽象基类。位于 io.agentscope.runtime.engine.services 包。核心成员包括 start、stop、health。
Abstract base class for services.
This class defines the interface that all services must implement. Services provide lifecycle management (start, stop, health check) and can be used with try-with-resources pattern for automatic cleanup.
Usage Example:
`Service service = new MyService();
// Manual lifecycle management
service.start().join();
try {
// Use service
boolean healthy = service.health().join();
} finally {
service.stop().join();
}
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void start() | 执行启动相关操作。 Starts the service, initializing any necessary resources or connections. |
public void stop() | 执行停止相关操作。 Stops the service, releasing any acquired resources. |
public boolean health() | 检查健康状态的服务。 Checks the health of the service. |
方法详情Method Detail
start
public void start()
执行启动相关操作。
Starts the service, initializing any necessary resources or connections.
源码Source
io/agentscope/runtime/engine/services/Service.java:45stop
public void stop()
执行停止相关操作。
Stops the service, releasing any acquired resources.
源码Source
io/agentscope/runtime/engine/services/Service.java:50health
public boolean health()
检查健康状态的服务。
Checks the health of the service.
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/runtime/engine/services/Service.java:57