AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.channel

ChannelLifecycleDispatcher

class ChannelLifecycleDispatcher
源码Source agentscope/app/channel/_dispatcher.py:54–257

渠道生命周期调度器,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.channel 包。核心成员包括 lifespan、reconcile、dispatch。

Reconciles this node's channel instances against storage. Declared in agentscope.app.channel.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(storage: StorageBase, message_bus: MessageBus, type_registry: ChannelTypeRegistry, gateway: ChannelGateway…
初始化 `ChannelLifecycleDispatcher` 实例。
Bind dependencies and start with an empty instance table.

方法摘要Method Summary

方法Method说明Description
async def lifespan() -> AsyncIterator[None]asyncasynccontextmanager
返回 `lifespan` 结果。
Start reconcile/heartbeat loops; stop all instances on exit.
async def reconcile() -> Noneasync
返回 `reconcile` 结果。
Drive the local instance set to match enabled records.
async def dispatch(event: ChannelEvent | ChannelConfirmationResultEvent, channel_id: str) -> Noneasync
执行 `dispatch` 方法。
Route an event through the gateway (used by tests).

构造器详情Constructor Detail

ChannelLifecycleDispatcher

def __init__(storage: StorageBase, message_bus: MessageBus, type_registry: ChannelTypeRegistry, gateway: ChannelGateway) -> None

初始化 ChannelLifecycleDispatcher 实例。

Bind dependencies and start with an empty instance table.

参数Parameters
名称Name类型Type说明Description
storageStorageBase存储(类型 `StorageBase`)。Source of truth for channel records.
message_busMessageBus消息总线(类型 `MessageBus`)。Lifecycle / outbound signalling.
type_registryChannelTypeRegistry类型注册表(类型 `ChannelTypeRegistry`)。Builds instances.
gatewayChannelGateway网关(类型 `ChannelGateway`)。Inbound event orchestrator bound into each started channel.
源码Source agentscope/app/channel/_dispatcher.py:57–79

方法详情Method Detail

lifespan

async def lifespan() -> AsyncIterator[None]
asyncasynccontextmanager

返回 lifespan 结果。

Start reconcile/heartbeat loops; stop all instances on exit.

返回Returns AsyncIterator[None]
以异步流的形式返回None。Returns a stream of none.
源码Source agentscope/app/channel/_dispatcher.py:82–97

reconcile

async def reconcile() -> None
async

返回 reconcile 结果。

Drive the local instance set to match enabled records.

返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/channel/_dispatcher.py:101–125

dispatch

async def dispatch(event: ChannelEvent | ChannelConfirmationResultEvent, channel_id: str) -> None
async

执行 dispatch 方法。

Route an event through the gateway (used by tests).

参数Parameters
名称Name类型Type说明Description
eventChannelEvent | ChannelConfirmationResultEvent事件到路由。The event to route.
channel_idstr渠道标识(类型 `str`)。The channel whose gateway handles it.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/channel/_dispatcher.py:243–257
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.