انتقل إلى المحتوى

مرجع واجهة ⁦node:diagnostics_channel⁩

قنوات تشخيص مسمّاة ومساعدات للتتبع

في هذه الصفحة
Open in ChatGPTOpen in Claude
import diagnostics from "node:diagnostics_channel";

const channel = diagnostics.channel("app.request");
const receive = (message, name) => console.log(name, message);

channel.subscribe(receive);
channel.publish({ path: "/" });
channel.unsubscribe(receive);

تعيد الاستدعاءات المتكررة لـ ⁦channel(name)⁩ الكائن ⁦Channel⁩ نفسه. وتصدّر الوحدة أيضًا ⁦hasSubscribers⁩ و⁦subscribe⁩ و⁦unsubscribe⁩ و⁦tracingChannel⁩ و⁦Channel⁩، وامتدادَي ⁦Elide⁩ ‏⁦boundedChannel⁩ و⁦BoundedChannel⁩.

تدعم القنوات ⁦bindStore⁩ و⁦unbindStore⁩ و⁦runStores⁩، لكن سلوك المخازن يرث الانتشار الجزئي لسياق التنفيذ غير المتزامن الموصوف في ⁦node:async_hooks⁩.

Reference

Status: Full · 42 of 67 suite tests pass (62.7%) · since 1.1.0

Exports

ExportKindStatusNotes
ChannelclassFullname, hasSubscribers, publish(), subscribe(), unsubscribe()
channel()functionFullReturns a Channel object for the given name, creating one if it does not exist
hasSubscribers()functionFullReturns whether the named channel has active subscribers
subscribe()functionFullSubscribe a handler to the named channel
unsubscribe()functionFullUnsubscribe a handler from the named channel

Tests: node-api node:diagnostics-channel: 42 pass, 25 fail, 0 error, 1 skipped. Failing: test-diagnostics-channel-http2-client-stream-body-multiple-buffers-and-strings.js, test-diagnostics-channel-http2-client-stream-body-multiple-buffers.js, test-diagnostics-channel-http2-client-stream-body-no-chunks.js, test-diagnostics-channel-http2-client-stream-body-single-buffer.js, test-diagnostics-channel-http2-client-stream-body-single-string.js, test-diagnostics-channel-http2-client-stream-close-error.js, test-diagnostics-channel-http2-client-stream-close.js, test-diagnostics-channel-http2-client-stream-created.js, and 17 more.

هل كانت هذه الصفحة مفيدة؟