ChannelManager
public final class ChannelManager
io/agentscope/harness/agent/gateway/ChannelManager.java:47–186渠道管理器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 register、unregister、getChannel、channelIds、getAllChannels、initAll。
Registry and lifecycle manager for Channel adapters. Provides outbound dispatch so the
gateway can deliver proactive messages (e.g. subagent announces) through the correct channel.
Lifecycle
-
#register(Channel)— add a channel to the registry -
#initAll(Gateway)— inject the gateway into all registered channels -
#startAll()— start all channels (connect to external transports) -
#stopAll()— stop all channels and release resources
Outbound delivery
#deliver(OutboundAddress, List) looks up the target channel by OutboundAddress#channelId() and delegates to Channel#deliver(OutboundAddress, List).
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public ChannelManager() | 初始化 `ChannelManager` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void register(Channel channel) | 设置注册。 Registers a channel adapter. |
public boolean unregister(String channelId) | 设置注销。 Stops and removes the channel registered under `channelId`, if any. |
public Optional<Channel> getChannel(String channelId) | 获取渠道。 Returns the channel registered under the given id, if any. |
public List<String> channelIds() | 返回 `channelIds` 结果。 Returns an unmodifiable snapshot of all registered channel ids. |
public Collection<Channel> getAllChannels() | 获取所有渠道。 Returns an unmodifiable snapshot of all registered channels. |
public void initAll(Gateway gateway) | 设置初始化所有。 Injects the gateway into all registered channels via `Channel#init(Gateway)`. |
public void startAll() | 启动所有。 Starts all registered channels. |
public void stopAll() | 停止所有。 Stops all registered channels and clears the registry. |
public boolean isStarted() | 判断是否已启动。 Whether `#startAll()` has been called. |
public void deliver(OutboundAddress address, List<Msg> messages) | 执行 `deliver` 方法。 Delivers proactive outbound messages through the channel identified by `OutboundAddress#channelId()`. |
构造器详情Constructor Detail
ChannelManager
public ChannelManager()
初始化 ChannelManager 实例。
Creates a new instance.
io/agentscope/harness/agent/gateway/ChannelManager.java:54方法详情Method Detail
register
public void register(Channel channel)
设置注册。
Registers a channel adapter.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
channel | Channel | 渠道(类型 `Channel`)。The channel. |
io/agentscope/harness/agent/gateway/ChannelManager.java:60–63unregister
public boolean unregister(String channelId)
设置注销。
Stops and removes the channel registered under channelId, if any.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
channelId | String | 渠道标识(类型 `String`)。The channel id. |
booleanio/agentscope/harness/agent/gateway/ChannelManager.java:70–89getChannel
public Optional<Channel> getChannel(String channelId)
获取渠道。
Returns the channel registered under the given id, if any.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
channelId | String | 渠道标识(类型 `String`)。The channel id. |
Optional<Channel>io/agentscope/harness/agent/gateway/ChannelManager.java:92–97channelIds
public List<String> channelIds()
返回 channelIds 结果。
Returns an unmodifiable snapshot of all registered channel ids.
List<String>io/agentscope/harness/agent/gateway/ChannelManager.java:100–102getAllChannels
public Collection<Channel> getAllChannels()
获取所有渠道。
Returns an unmodifiable snapshot of all registered channels.
Collection<Channel>io/agentscope/harness/agent/gateway/ChannelManager.java:105–107initAll
public void initAll(Gateway gateway)
设置初始化所有。
Injects the gateway into all registered channels via Channel#init(Gateway).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
gateway | Gateway | 网关(类型 `Gateway`)。The gateway. |
io/agentscope/harness/agent/gateway/ChannelManager.java:113–122startAll
public void startAll()
启动所有。
Starts all registered channels.
io/agentscope/harness/agent/gateway/ChannelManager.java:125–135stopAll
public void stopAll()
停止所有。
Stops all registered channels and clears the registry.
io/agentscope/harness/agent/gateway/ChannelManager.java:138–148isStarted
public boolean isStarted()
判断是否已启动。
Whether #startAll() has been called.
booleanio/agentscope/harness/agent/gateway/ChannelManager.java:151–153deliver
public void deliver(OutboundAddress address, List<Msg> messages)
执行 deliver 方法。
Delivers proactive outbound messages through the channel identified by OutboundAddress#channelId().
| 名称Name | 类型Type | 说明Description |
|---|---|---|
address | OutboundAddress | address(类型 `OutboundAddress`)。the delivery target |
messages | List<Msg> | 消息列表(类型 `List`)。the messages to deliver |
io/agentscope/harness/agent/gateway/ChannelManager.java:163–185