Skip to main content

Class: MessageClient

Defined in: packages/messaging/src/sender.ts:132

send(): one way to call a module, whichever carrier moves the message. The adapter is chosen by the static hosting table (isInProcess): a listed caller co-hosted with the server goes in process; anything else goes over the broker. The caller cannot override it, because it is code, not configuration.

Constructors​

Constructor​

new MessageClient(options): MessageClient

Defined in: packages/messaging/src/sender.ts:143

Parameters​

options​

MessageClientOptions

Returns​

MessageClient

Methods​

declareEdges()​

declareEdges(keys): void

Defined in: packages/messaging/src/sender.ts:163

Declares, at start, every request this caller will make. A client that cannot make an edge does not start: the key must be registered, the permission table must list this caller against it, and a co-hosted edge needs the bus.

Parameters​

keys​

readonly RequestKey[]

The registry keys the caller will call.

Returns​

void

Throws​

An edge is unregistered, unlisted, or has no carrier.


request()​

request<K>(key, call): Promise<ReplyOf<K>>

Defined in: packages/messaging/src/sender.ts:205

Calls a module and waits for its reply.

Never throws for a runtime failure: a refusal, an expired deadline, a missing responder and a bad reply are all Reply errors with the category the caller should act on. A programming error (an unregistered key) does throw, at the first call, which is why MessageClient.declareEdges exists.

Type Parameters​

K​

K extends RequestKey

Parameters​

key​

K

The registry key.

call​

RequestCall<K>

The body, the actor and the envelope fields.

Returns​

Promise<ReplyOf<K>>

The reply, typed by the contract.