Static
订阅创建一个订阅单个通道的 PregelNode。这用于定义节点如何从通道接收输入。
要订阅的单个通道名称
Optional
options: SingleChannelSubscriptionOptions订阅选项
配置为从指定通道接收数据的 PregelNode
// Subscribe to a single channel
const node = Channel.subscribeTo("messages");
// Subscribe to multiple channels
const node = Channel.subscribeTo(["messages", "state"]);
// Subscribe with a custom key
const node = Channel.subscribeTo("messages", { key: "chat" });
如果订阅多个通道时指定了键
创建一个订阅多个通道的 PregelNode。这用于定义节点如何从通道接收输入。
Optional
options: MultipleChannelSubscriptionOptions订阅选项
配置为从指定通道接收数据的 PregelNode
// Subscribe to a single channel
const node = Channel.subscribeTo("messages");
// Subscribe to multiple channels
const node = Channel.subscribeTo(["messages", "state"]);
// Subscribe with a custom key
const node = Channel.subscribeTo("messages", { key: "chat" });
如果订阅多个通道时指定了键
Static
写入创建一个 ChannelWrite,用于指定如何将值写入通道。这用于定义节点如何向通道发送输出。
要写入的通道名称数组
Optional
writes: Record<string, unknown>通道名称到值或转换的可选映射
可用于向指定通道写入的 ChannelWrite 对象
// Write to multiple channels
const write = Channel.writeTo(["output", "state"]);
// Write with specific values
const write = Channel.writeTo(["output"], {
state: "completed",
result: calculateResult()
});
// Write with a transformation function
const write = Channel.writeTo(["output"], {
result: (x) => processResult(x)
});
用于在 Pregel 系统中处理通道的实用类。提供用于订阅通道和向其写入的静态方法。
通道是 Pregel 图中节点之间的通信路径。它们实现图的不同部分之间的消息传递和状态更新。