ServiceBroker
Defined in: packages/hoppity/src/broker/types.ts:13
The fully-wired broker returned by ServiceBuilder.build().
Extends BrokerAsPromised with typed outbound methods derived from the service’s contracts. These methods are monkey-patched onto the broker instance during the outbound wiring phase.
Extends
Section titled “Extends”BrokerAsPromised
Properties
Section titled “Properties”config
Section titled “config”
readonlyconfig:BrokerConfig
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:458
Inherited from
Section titled “Inherited from”BrokerAsPromised.config
Methods
Section titled “Methods”[captureRejectionSymbol]()?
Section titled “[captureRejectionSymbol]()?”
optional[captureRejectionSymbol]<K>(error,event, …args):void
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:136
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”Error
string | symbol
…AnyRest
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”BrokerAsPromised.[captureRejectionSymbol]
addListener()
Section titled “addListener()”addListener<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:597
Alias for emitter.on(eventName, listener).
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string | symbol
listener
Section titled “listener”(…args) => void
Returns
Section titled “Returns”this
v0.1.26
Inherited from
Section titled “Inherited from”BrokerAsPromised.addListener
bounce()
Section titled “bounce()”bounce():
Promise<void>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:465
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”BrokerAsPromised.bounce
cancelRequest()
Section titled “cancelRequest()”cancelRequest(
correlationId):boolean
Defined in: packages/hoppity/src/broker/types.ts:56
Cancels a pending RPC request by correlation ID. Returns true if the request was found and cancelled, false if not found.
Parameters
Section titled “Parameters”correlationId
Section titled “correlationId”string
Returns
Section titled “Returns”boolean
connect()
Section titled “connect()”connect(
name):Promise<Connection>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:461
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<Connection>
Inherited from
Section titled “Inherited from”BrokerAsPromised.connect
emit()
Section titled “emit()”emit<
K>(eventName, …args):boolean
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:859
Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments
to each.
Returns true if the event had listeners, false otherwise.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string | symbol
…AnyRest
Returns
Section titled “Returns”boolean
v0.1.26
Inherited from
Section titled “Inherited from”BrokerAsPromised.emit
eventNames()
Section titled “eventNames()”eventNames(): (
string|symbol)[]
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:922
Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbols.
Returns
Section titled “Returns”(string | symbol)[]
v6.0.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.eventNames
forward()
Section titled “forward()”forward(
name,message,overrides?):Promise<PublicationSession>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:467
Parameters
Section titled “Parameters”string
message
Section titled “message”any
overrides?
Section titled “overrides?”string | PublicationConfig
Returns
Section titled “Returns”Promise<PublicationSession>
Inherited from
Section titled “Inherited from”BrokerAsPromised.forward
getConnections()
Section titled “getConnections()”getConnections():
ConnectionDetails[]
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:471
Returns
Section titled “Returns”ConnectionDetails[]
Inherited from
Section titled “Inherited from”BrokerAsPromised.getConnections
getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:774
Returns the current max listener value for the EventEmitter which is either
set by emitter.setMaxListeners(n) or defaults to EventEmitter.defaultMaxListeners.
Returns
Section titled “Returns”number
v1.0.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.getMaxListeners
listenerCount()
Section titled “listenerCount()”listenerCount<
K>(eventName,listener?):number
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:868
Returns the number of listeners listening for the event named eventName.
If listener is provided, it will return how many times the listener is found
in the list of the listeners of the event.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”The name of the event being listened for
string | symbol
listener?
Section titled “listener?”Function
The event handler function
Returns
Section titled “Returns”number
v3.2.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.listenerCount
listeners()
Section titled “listeners()”listeners<
K>(eventName):Function[]
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:787
Returns a copy of the array of listeners for the event named eventName.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string | symbol
Returns
Section titled “Returns”Function[]
v0.1.26
Inherited from
Section titled “Inherited from”BrokerAsPromised.listeners
nuke()
Section titled “nuke()”nuke():
Promise<void>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:462
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”BrokerAsPromised.nuke
off<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:747
Alias for emitter.removeListener().
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string | symbol
listener
Section titled “listener”(…args) => void
Returns
Section titled “Returns”this
v10.0.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.off
on<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:629
Adds the listener function to the end of the listeners array for the event
named eventName. No checks are made to see if the listener has already
been added. Multiple calls passing the same combination of eventName and
listener will result in the listener being added, and called, multiple times.
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”The name of the event.
string | symbol
listener
Section titled “listener”(…args) => void
The callback function
Returns
Section titled “Returns”this
v0.1.101
Inherited from
Section titled “Inherited from”BrokerAsPromised.on
once()
Section titled “once()”once<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:659
Adds a one-time listener function for the event named eventName. The
next time eventName is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the
event listener to the beginning of the listeners array.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”The name of the event.
string | symbol
listener
Section titled “listener”(…args) => void
The callback function
Returns
Section titled “Returns”this
v0.3.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.once
prependListener()
Section titled “prependListener()”prependListener<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:886
Adds the listener function to the beginning of the listeners array for the
event named eventName. No checks are made to see if the listener has
already been added. Multiple calls passing the same combination of eventName
and listener will result in the listener being added, and called, multiple times.
Returns a reference to the EventEmitter, so that calls can be chained.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”The name of the event.
string | symbol
listener
Section titled “listener”(…args) => void
The callback function
Returns
Section titled “Returns”this
v6.0.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.prependListener
prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:902
Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this
listener is removed, and then invoked.
Returns a reference to the EventEmitter, so that calls can be chained.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”The name of the event.
string | symbol
listener
Section titled “listener”(…args) => void
The callback function
Returns
Section titled “Returns”this
v6.0.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.prependOnceListener
publish()
Section titled “publish()”publish(
name,message,overrides?):Promise<PublicationSession>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:466
Parameters
Section titled “Parameters”string
message
Section titled “message”any
overrides?
Section titled “overrides?”string | PublicationConfig
Returns
Section titled “Returns”Promise<PublicationSession>
Inherited from
Section titled “Inherited from”BrokerAsPromised.publish
publishEvent()
Section titled “publishEvent()”publishEvent<
TSchema>(contract,message,overrides?):Promise<void>
Defined in: packages/hoppity/src/broker/types.ts:23
Publishes an event payload using the contract’s derived publication name. Validates the payload against the contract schema if validateOutbound is enabled.
When overrides include delay, the message is routed through delayed delivery
(published to the wait queue with per-message TTL). The contract must declare
delay support or a runtime error is thrown. delay: true uses the contract’s
default delay; delay: number overrides it.
Type Parameters
Section titled “Type Parameters”TSchema
Section titled “TSchema”TSchema extends ZodTypeAny
Parameters
Section titled “Parameters”contract
Section titled “contract”EventContract<any, any, TSchema>
message
Section titled “message”TypeOf<TSchema>
overrides?
Section titled “overrides?”PublicationConfig & object
Returns
Section titled “Returns”Promise<void>
purge()
Section titled “purge()”purge():
Promise<void>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:463
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”BrokerAsPromised.purge
rawListeners()
Section titled “rawListeners()”rawListeners<
K>(eventName):Function[]
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:818
Returns a copy of the array of listeners for the event named eventName,
including any wrappers (such as those created by .once()).
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string | symbol
Returns
Section titled “Returns”Function[]
v9.4.0
Inherited from
Section titled “Inherited from”BrokerAsPromised.rawListeners
removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners(
eventName?):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:758
Removes all listeners, or those of the specified eventName.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter instance was created by some other
component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter, so that calls can be chained.
Parameters
Section titled “Parameters”eventName?
Section titled “eventName?”string | symbol
Returns
Section titled “Returns”this
v0.1.26
Inherited from
Section titled “Inherited from”BrokerAsPromised.removeAllListeners
removeListener()
Section titled “removeListener()”removeListener<
K>(eventName,listener):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:742
Removes the specified listener from the listener array for the event named eventName.
removeListener() will remove, at most, one instance of a listener from the
listener array. If any single listener has been added multiple times to the
listener array for the specified eventName, then removeListener() must be
called multiple times to remove each instance.
Once an event is emitted, all listeners attached to it at the
time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution
will not remove them fromemit() in progress. Subsequent events behave as expected.
Because listeners are managed using an internal array, calling this will
change the position indices of any listener registered after the listener
being removed. This will not impact the order in which listeners are called,
but it means that any copies of the listener array as returned by
the emitter.listeners() method will need to be recreated.
When a single function has been added as a handler multiple times for a single
event (as in the example below), removeListener() will remove the most
recently added instance. In the example the once('ping') listener is removed:
Returns a reference to the EventEmitter, so that calls can be chained.
Type Parameters
Section titled “Type Parameters”K
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string | symbol
listener
Section titled “listener”(…args) => void
Returns
Section titled “Returns”this
v0.1.26
Inherited from
Section titled “Inherited from”BrokerAsPromised.removeListener
request()
Section titled “request()”request<
TReq,TRes>(contract,message,overrides?):Promise<TypeOf<TRes>>
Defined in: packages/hoppity/src/broker/types.ts:46
Makes an RPC call and returns a Promise resolving to the response. Times out after defaultTimeout ms (default 30s). Validates request if validateOutbound is enabled, validates response if validateInbound is enabled.
Type Parameters
Section titled “Type Parameters”TReq extends ZodTypeAny
TRes extends ZodTypeAny
Parameters
Section titled “Parameters”contract
Section titled “contract”RpcContract<any, any, TReq, TRes>
message
Section titled “message”TypeOf<TReq>
overrides?
Section titled “overrides?”PublicationConfig
Returns
Section titled “Returns”Promise<TypeOf<TRes>>
sendCommand()
Section titled “sendCommand()”sendCommand<
TSchema>(contract,message,overrides?):Promise<void>
Defined in: packages/hoppity/src/broker/types.ts:35
Sends a command payload using the contract’s derived publication name. Validates the payload against the contract schema if validateOutbound is enabled.
Supports the same delay option as publishEvent — see that method for details.
Type Parameters
Section titled “Type Parameters”TSchema
Section titled “TSchema”TSchema extends ZodTypeAny
Parameters
Section titled “Parameters”contract
Section titled “contract”CommandContract<any, any, TSchema>
message
Section titled “message”TypeOf<TSchema>
overrides?
Section titled “overrides?”PublicationConfig & object
Returns
Section titled “Returns”Promise<void>
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n):this
Defined in: node_modules/.pnpm/@types+node@20.19.2/node_modules/@types/node/events.d.ts:768
By default EventEmitters will print a warning if more than 10 listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. The emitter.setMaxListeners() method allows the limit to be
modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter, so that calls can be chained.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
v0.3.5
Inherited from
Section titled “Inherited from”BrokerAsPromised.setMaxListeners
shutdown()
Section titled “shutdown()”shutdown():
Promise<void>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:464
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”BrokerAsPromised.shutdown
subscribe()
Section titled “subscribe()”subscribe(
name,overrides?):Promise<SubscriberSessionAsPromised>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:469
Parameters
Section titled “Parameters”string
overrides?
Section titled “overrides?”SubscriptionConfig
Returns
Section titled “Returns”Promise<SubscriberSessionAsPromised>
Inherited from
Section titled “Inherited from”BrokerAsPromised.subscribe
subscribeAll()
Section titled “subscribeAll()”subscribeAll(
filter?):Promise<SubscriberSessionAsPromised[]>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:470
Parameters
Section titled “Parameters”filter?
Section titled “filter?”(config) => boolean
Returns
Section titled “Returns”Promise<SubscriberSessionAsPromised[]>
Inherited from
Section titled “Inherited from”BrokerAsPromised.subscribeAll
unsubscribeAll()
Section titled “unsubscribeAll()”unsubscribeAll():
Promise<void>
Defined in: node_modules/.pnpm/@types+rascal@10.2.1/node_modules/@types/rascal/index.d.ts:468
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”BrokerAsPromised.unsubscribeAll