Send / Publish / Request / Reply Options
Overview
Section titled “Overview”Every outgoing call on the Bus takes a small, purpose-built options object. They share the same headers shape (an immutable record of string-to-string custom headers) but otherwise capture exactly what each call needs — an endpoint for send, a routing key for publish, a timeout and optional signal for requests, headers only for replies.
Import
Section titled “Import”import { DEFAULT_REQUEST_TIMEOUT_MS } from '@serviceconnect/core';import type { PublishOptions, ReplyOptions, RequestOptions, SendOptions,} from '@serviceconnect/core';SendOptions
Section titled “SendOptions”export interface SendOptions { readonly headers?: Readonly<Record<string, string>>; readonly endpoint: string;}endpoint(required) — the destination queue / endpoint name to send to. Stamped onto the outgoing envelope asdestinationAddress.headers(optional) — extra string-valued headers merged into the envelope before the outgoing pipeline runs. Bus-managed headersmessageType,sourceAddress, andtimeSentare stamped unconditionally and override any caller-supplied value (destinationAddressis set fromendpoint).messageIdis the exception: a caller-suppliedmessageIdis kept, and the bus only auto-generates one when it is absent.correlationIdis not a header — it travels on the message body — so it is not stamped here.
PublishOptions
Section titled “PublishOptions”export interface PublishOptions { readonly headers?: Readonly<Record<string, string>>; readonly routingKey?: string;}routingKey(optional) — the broker-level routing key. With RabbitMQ this maps to AMQP’s routing key on the type’s exchange; with other transports it is interpreted by the adapter.headers(optional) — same semantics asSendOptions.headers.
RequestOptions
Section titled “RequestOptions”export interface RequestOptions { readonly headers?: Readonly<Record<string, string>>; readonly endpoint?: string; readonly timeoutMs?: number; readonly expectedReplyCount?: number; readonly signal?: AbortSignal;}endpoint(optional) — point-to-point destination. If omitted the request is published; if set it is sent.timeoutMs(optional, required forsendRequest) — milliseconds before the pending request rejects withRequestTimeoutError(or, forsendRequestMulti, resolves with however many replies arrived).expectedReplyCount(optional) — used bysendRequestMultito short-circuit once the expected number of replies has arrived without waiting for the full timeout.signal(optional) — caller-suppliedAbortSignal. When the signal aborts before a reply arrives the request rejects withAbortError.headers(optional) — extra headers merged into the outgoing request envelope.
ReplyOptions
Section titled “ReplyOptions”export interface ReplyOptions { readonly headers?: Readonly<Record<string, string>>;}headers(optional) — extra headers merged into the reply envelope. The reply already stampsresponseMessageId(echoing the inbound request’srequestMessageId) anddestinationAddress(the inbound request’ssourceAddress), so you only need this for application-specific headers.
DEFAULT_REQUEST_TIMEOUT_MS
Section titled “DEFAULT_REQUEST_TIMEOUT_MS”export const DEFAULT_REQUEST_TIMEOUT_MS = 10_000;The default request timeout in milliseconds (10_000). It documents the intended default, but the bus does not actually read this exported constant: the only code path that applies a default — publishRequest — inlines the literal 10_000 independently. BusOptions.defaultRequestTimeout is currently inert (declared but never consumed) and plays no part in any fallback. sendRequest and sendRequestMulti apply no default at all — they require a positive timeoutMs on the call site and otherwise throw ArgumentOutOfRangeError.