ServiceWithLifecycleManager
public abstract class ServiceWithLifecycleManager implements Service
源码Source
io/agentscope/runtime/engine/services/ServiceWithLifecycleManager.java:51–72服务使用生命周期管理器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.engine.services 包,实现 Service。核心成员包括 start、stop、health。
Base class for services that want lifecycle manager functionality.
This class combines the Service interface with default implementations for common lifecycle operations, providing a convenient base class for most service implementations.
Note: This is an abstract base class. Subclasses must implement the abstract methods from the Service interface.
Usage Example:
`public class MyService extends ServiceWithLifecycleManager {
@Override
public CompletableFuture<Void> start() {
// Initialize resources
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Void> stop() {
// Cleanup resources
return CompletableFuture.completedFuture(null);
}
@Override
public CompletableFuture<Boolean> health() {
return CompletableFuture.completedFuture(true);
}
}
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public abstract void start()abstract | 执行启动相关操作。 Starts the service, initializing any necessary resources or connections. |
public abstract void stop()abstract | 执行停止相关操作。 Stops the service, releasing any acquired resources. |
public abstract boolean health()abstract | 检查健康状态的服务。 Checks the health of the service. |
方法详情Method Detail
start
public abstract void start()
abstract
执行启动相关操作。
Starts the service, initializing any necessary resources or connections.
源码Source
io/agentscope/runtime/engine/services/ServiceWithLifecycleManager.java:56–57stop
public abstract void stop()
abstract
执行停止相关操作。
Stops the service, releasing any acquired resources.
源码Source
io/agentscope/runtime/engine/services/ServiceWithLifecycleManager.java:62–63health
public abstract boolean health()
abstract
检查健康状态的服务。
Checks the health of the service.
boolean返回布尔值,表示判断结果。Returns a boolean result.
源码Source
io/agentscope/runtime/engine/services/ServiceWithLifecycleManager.java:70–71