channel.publish(message)
message<any> 要发送给通道订阅者的消息
向通道的任何订阅者发布消息。这将同步触发消息处理程序,使它们在相同的上下文中执行。
【Publish a message to any subscribers to the channel. This will trigger message handlers synchronously so they will execute within the same context.】
import diagnostics_channel from 'node:diagnostics_channel';
const channel = diagnostics_channel.channel('my-channel');
channel.publish({
some: 'message',
});const diagnostics_channel = require('node:diagnostics_channel');
const channel = diagnostics_channel.channel('my-channel');
channel.publish({
some: 'message',
});