Interface: BroadcastContext<Request, Response>
Makaio Framework / bus-core / BroadcastContext
Interface: BroadcastContext<Request, Response>
Section titled “Interface: BroadcastContext<Request, Response>”Defined in: ../../../packages/bus-core/src/methods/broadcast.ts:31
Extended request context for broadcast handlers. Adds identify() method to tag responses with a node identifier.
Extends
Section titled “Extends”RequestContext<Request,Response>
Type Parameters
Section titled “Type Parameters”Request
Section titled “Request”Request
Response
Section titled “Response”Response
Properties
Section titled “Properties”correlationId?
Section titled “correlationId?”
optionalcorrelationId?:string
Defined in: ../../../packages/makaio-core/src/types/message.ts:95
Optional identifier linking related operations. Propagated through chains of requests/events.
Used for:
- Distributed tracing
- Causality tracking
- Following a workflow through the system
Example
Section titled “Example”// Initial request generates correlationIdconst result = await request( UserSubjects.getUser, { userId: '42' }, { correlationId: 'user-action-123' });
// Handler propagates correlationId to downstream operationsawait emit( UserSubjects.userLoaded, { user: result }, { correlationId: context.correlationId });Inherited from
Section titled “Inherited from”RequestContext.correlationId
extendResult
Section titled “extendResult”extendResult: (
extension) =>void
Defined in: ../../../packages/makaio-core/src/types/context.ts:61
Shallow-merge additional fields into the current result.
Only valid for object-typed responses. In the request path the operation
uses spread (immutable); in broadcast mode it uses Object.assign
(in-place mutation) so the already-pushed result reference stays current.
If no result has been set yet, starts from an empty object.
Parameters
Section titled “Parameters”extension
Section titled “extension”[Response] extends [Record<string, unknown>] ? Partial<Response> : never
Fields to merge into the current result
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”RequestContext.extendResult
identify
Section titled “identify”identify: (
nodeId) =>void
Defined in: ../../../packages/bus-core/src/methods/broadcast.ts:37
Identify this handler for broadcast aggregation. Call before setResult() to tag the response with a nodeId.
Parameters
Section titled “Parameters”nodeId
Section titled “nodeId”string
Unique identifier for this handler/node
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”RequestContext.identify
isRequest
Section titled “isRequest”isRequest:
true
Defined in: ../../../packages/makaio-core/src/types/context.ts:36
Discriminator - always true for requests
Inherited from
Section titled “Inherited from”RequestContext.isRequest
messageId
Section titled “messageId”messageId:
string
Defined in: ../../../packages/makaio-core/src/types/message.ts:68
Unique identifier for this specific message. Auto-generated if not provided.
Used for:
- Message deduplication
- Idempotency checks
- Tracking individual messages in logs
Inherited from
Section titled “Inherited from”RequestContext.messageId
next: () =>
Promise<void>
Defined in: ../../../packages/makaio-core/src/types/context.ts:67
Call the next handler in the middleware chain. If no more handlers exist, throws NoHandlerError.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”RequestContext.next
payload
Section titled “payload”payload:
Request
Defined in: ../../../packages/makaio-core/src/types/context.ts:39
The request payload
Inherited from
Section titled “Inherited from”RequestContext.payload
replacePayload
Section titled “replacePayload”replacePayload: (
newPayload) =>void
Defined in: ../../../packages/makaio-core/src/types/context.ts:74
Replace the payload with a new value. Subsequent handlers in the middleware chain will receive the new payload. Useful for hooks that need to inject context before the main handler runs.
Parameters
Section titled “Parameters”newPayload
Section titled “newPayload”Request
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”RequestContext.replacePayload
result
Section titled “result”
readonlyresult:Response|undefined
Defined in: ../../../packages/makaio-core/src/types/context.ts:50
Read the current result value.
Returns the value set by setResult() in this handler or by a downstream
handler after await next(). Undefined until a result has been set.
Inherited from
Section titled “Inherited from”RequestContext.result
setResult
Section titled “setResult”setResult: (
result) =>void
Defined in: ../../../packages/makaio-core/src/types/context.ts:42
Set the response value (ends the handler chain)
Parameters
Section titled “Parameters”result
Section titled “result”Response
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”RequestContext.setResult
transport?
Section titled “transport?”
optionaltransport?:TransportReceiveContext
Defined in: ../../../packages/makaio-core/src/types/message.ts:103
Trusted context supplied by the local receiving transport.
Undefined for local calls and for transports that do not supply connection context. Never trust similarly named fields in payloads or wire messages.
Inherited from
Section titled “Inherited from”RequestContext.transport