类class
agentscope.app.channelChannelLifecycleDispatcher
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 |
|---|---|---|
storage | StorageBase | 存储(类型 `StorageBase`)。Source of truth for channel records. |
message_bus | MessageBus | 消息总线(类型 `MessageBus`)。Lifecycle / outbound signalling. |
type_registry | ChannelTypeRegistry | 类型注册表(类型 `ChannelTypeRegistry`)。Builds instances. |
gateway | ChannelGateway | 网关(类型 `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.
AsyncIterator[None]
以异步流的形式返回None。Returns a stream of none.
源码Source
agentscope/app/channel/_dispatcher.py:82–97reconcile
async def reconcile() -> None
async
返回 reconcile 结果。
Drive the local instance set to match enabled records.
None
无返回值。No value is returned.
源码Source
agentscope/app/channel/_dispatcher.py:101–125dispatch
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 |
|---|---|---|
event | ChannelEvent | ChannelConfirmationResultEvent | 事件到路由。The event to route. |
channel_id | str | 渠道标识(类型 `str`)。The channel whose gateway handles it. |
None
无返回值。No value is returned.
源码Source
agentscope/app/channel/_dispatcher.py:243–257