@codesoul-co/hypha-core / modules/runtime/message-bus
- Package index:
@codesoul-co/hypha-core - Source:
packages/core/src/modules/runtime/message-bus.ts - Exports: 14
Using this module
Use the Message bus module for executing runtime behavior at this boundary. It exports 1 class, 7 functions, 6 interfaces.
Import from the package entrypoint
import {
InMemoryMessageBus,
addMilliseconds,
busError,
createRuntimeMessageEnvelope,
isAtOrBefore,
nonEmpty,
nonNegative,
positive,
} from '@codesoul-co/hypha-core';
import type {
InMemoryMessageBusOptions,
MessageBus,
MessageDelivery,
MessagePublishRequest,
MessagePublishResult,
MessageSubscriptionRequest,
} from '@codesoul-co/hypha-core';Usage patterns
- Use the 6 type/interface exports as static contracts in application code, adapters, or tests. Import them with
import type; they do not exist at runtime. - The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
- The module exposes 7 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
InMemoryMessageBus | class | new InMemoryMessageBus(options?: InMemoryMessageBusOptions): InMemoryMessageBus | In Memory Message Bus class with 7 public constructor or member entries; its exact declarations are listed below. |
addMilliseconds | function | addMilliseconds(timestamp: string, milliseconds: number): string | Add Milliseconds function with 1 public call signature; parameters and return types are listed below. |
busError | function | busError(code: string, message: string, context?: Record<string, unknown>): FrameworkError | Bus Error function with 1 public call signature; parameters and return types are listed below. |
createRuntimeMessageEnvelope | function | createRuntimeMessageEnvelope<TPayload>(input: RuntimeMessageEnvelopeInput<TPayload>): RuntimeMessageEnvelope<TPayload> | Create Runtime Message Envelope function with 1 public call signature; parameters and return types are listed below. |
isAtOrBefore | function | isAtOrBefore(left: string, right: string): boolean | Is At Or Before function with 1 public call signature; parameters and return types are listed below. |
nonEmpty | function | nonEmpty(value: unknown, label: string): asserts value is string | Non Empty function with 1 public call signature; parameters and return types are listed below. |
nonNegative | function | nonNegative(value: number, label?: string): number | Non Negative function with 1 public call signature; parameters and return types are listed below. |
positive | function | positive(value: number, label: string): number | Positive function with 1 public call signature; parameters and return types are listed below. |
InMemoryMessageBusOptions | interface | interface InMemoryMessageBusOptions | In Memory Message Bus Options interface with 6 public fields or methods. |
MessageBus | interface | interface MessageBus | Message Bus interface with 5 public fields or methods. |
MessageDelivery | interface | interface MessageDelivery | Message Delivery interface with 9 public fields or methods. |
MessagePublishRequest | interface | interface MessagePublishRequest | Message Publish Request interface with 1 public fields or methods. |
MessagePublishResult | interface | interface MessagePublishResult | Message Publish Result interface with 6 public fields or methods. |
MessageSubscriptionRequest | interface | interface MessageSubscriptionRequest | Message Subscription Request interface with 8 public fields or methods. |
InMemoryMessageBus
In Memory Message Bus class with 7 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { InMemoryMessageBus } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare class InMemoryMessageBus implements MessageBus {
constructor(options?: InMemoryMessageBusOptions);
publish<TPayload>(request: MessagePublishRequest<TPayload>): Promise<MessagePublishResult>;
publishBatch<TPayload>(requests: MessagePublishRequest<TPayload>[]): Promise<MessagePublishResult[]>;
subscribe<TPayload>(request: MessageSubscriptionRequest): AsyncIterable<MessageDelivery<TPayload>>;
health(): Promise<ProviderHealth>;
close(): Promise<void>;
listDeadLetters(consumerGroup: string): RuntimeMessageEnvelope[];
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
close | method | close(): Promise<void> | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (options?: InMemoryMessageBusOptions): InMemoryMessageBus | Creates an instance of this class. |
health | method | health(): Promise<ProviderHealth> | Public method; parameters and return type are shown in the signature. |
listDeadLetters | method | listDeadLetters(consumerGroup: string): RuntimeMessageEnvelope[] | Public method; parameters and return type are shown in the signature. |
publish | method | publish<TPayload>(request: MessagePublishRequest<TPayload>): Promise<MessagePublishResult> | Public method; parameters and return type are shown in the signature. |
publishBatch | method | publishBatch<TPayload>(requests: MessagePublishRequest<TPayload>[]): Promise<MessagePublishResult[]> | Public method; parameters and return type are shown in the signature. |
subscribe | method | subscribe<TPayload>(request: MessageSubscriptionRequest): AsyncIterable<MessageDelivery<TPayload>> | Public method; parameters and return type are shown in the signature. |
addMilliseconds
Add Milliseconds function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { addMilliseconds } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function addMilliseconds(timestamp: string, milliseconds: number): string;Call signature
addMilliseconds(timestamp: string, milliseconds: number): stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | string | Yes | Required parameter; accepted values are defined by the type column. |
milliseconds | number | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
string - Description: The return contract is defined by the type shown above.
busError
Bus Error function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { busError } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function busError(code: string, message: string, context?: Record<string, unknown>): FrameworkError;Call signature
busError(code: string, message: string, context?: Record<string, unknown>): FrameworkErrorParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Required parameter; accepted values are defined by the type column. |
message | string | Yes | Required parameter; accepted values are defined by the type column. |
context | Record<string, unknown> | No | Optional parameter; accepted values are defined by the type column. |
Returns
- Type:
FrameworkError - Description: The return contract is defined by the type shown above.
createRuntimeMessageEnvelope
Create Runtime Message Envelope function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { createRuntimeMessageEnvelope } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function createRuntimeMessageEnvelope<TPayload>(input: RuntimeMessageEnvelopeInput<TPayload>): RuntimeMessageEnvelope<TPayload>;Call signature
createRuntimeMessageEnvelope<TPayload>(input: RuntimeMessageEnvelopeInput<TPayload>): RuntimeMessageEnvelope<TPayload>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | RuntimeMessageEnvelopeInput<TPayload> | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
RuntimeMessageEnvelope<TPayload> - Description: The return contract is defined by the type shown above.
isAtOrBefore
Is At Or Before function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { isAtOrBefore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function isAtOrBefore(left: string, right: string): boolean;Call signature
isAtOrBefore(left: string, right: string): booleanParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
left | string | Yes | Required parameter; accepted values are defined by the type column. |
right | string | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
boolean - Description: The return contract is defined by the type shown above.
nonEmpty
Non Empty function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { nonEmpty } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function nonEmpty(value: unknown, label: string): asserts value is string;Call signature
nonEmpty(value: unknown, label: string): asserts value is stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value | unknown | Yes | Required parameter; accepted values are defined by the type column. |
label | string | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
asserts value is string - Description: The return contract is defined by the type shown above.
nonNegative
Non Negative function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { nonNegative } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function nonNegative(value: number, label?: string): number;Call signature
nonNegative(value: number, label?: string): numberParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Required parameter; accepted values are defined by the type column. |
label | string | No | Optional parameter; accepted values are defined by the type column. |
Returns
- Type:
number - Description: The return contract is defined by the type shown above.
positive
Positive function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { positive } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export declare function positive(value: number, label: string): number;Call signature
positive(value: number, label: string): numberParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Required parameter; accepted values are defined by the type column. |
label | string | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
number - Description: The return contract is defined by the type shown above.
InMemoryMessageBusOptions
In Memory Message Bus Options interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { InMemoryMessageBusOptions } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export interface InMemoryMessageBusOptions {
now?: () => string;
maxDeliveryAttempts?: number;
defaultAckDeadlineMs?: number;
maxMessageBytes?: number;
maxQueueDepth?: number;
pollIntervalMs?: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
defaultAckDeadlineMs | property | defaultAckDeadlineMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxDeliveryAttempts | property | maxDeliveryAttempts?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxMessageBytes | property | maxMessageBytes?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxQueueDepth | property | maxQueueDepth?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
now | method | now?(): string | Public method; parameters and return type are shown in the signature. |
pollIntervalMs | property | pollIntervalMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
MessageBus
Message Bus interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { MessageBus } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export interface MessageBus {
publish<TPayload>(request: MessagePublishRequest<TPayload>): Promise<MessagePublishResult>;
publishBatch<TPayload>(requests: MessagePublishRequest<TPayload>[]): Promise<MessagePublishResult[]>;
subscribe<TPayload>(request: MessageSubscriptionRequest): AsyncIterable<MessageDelivery<TPayload>>;
health(): Promise<ProviderHealth>;
close(): Promise<void>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
close | method | close(): Promise<void> | Public method; parameters and return type are shown in the signature. |
health | method | health(): Promise<ProviderHealth> | Public method; parameters and return type are shown in the signature. |
publish | method | publish<TPayload>(request: MessagePublishRequest<TPayload>): Promise<MessagePublishResult> | Public method; parameters and return type are shown in the signature. |
publishBatch | method | publishBatch<TPayload>(requests: MessagePublishRequest<TPayload>[]): Promise<MessagePublishResult[]> | Public method; parameters and return type are shown in the signature. |
subscribe | method | subscribe<TPayload>(request: MessageSubscriptionRequest): AsyncIterable<MessageDelivery<TPayload>> | Public method; parameters and return type are shown in the signature. |
MessageDelivery
Message Delivery interface with 9 public fields or methods.
- Kind: interface
- Import:
import type { MessageDelivery } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export interface MessageDelivery<TPayload = unknown> {
envelope: RuntimeMessageEnvelope<TPayload>;
deliveryId: string;
attempt: number;
receivedAt: string;
ackDeadlineAt: string;
ack(): Promise<void>;
nack(options?: {
delayMs?: number;
reason?: string;
}): Promise<void>;
deadLetter(reason: string): Promise<void>;
extendAckDeadline(extensionMs: number): Promise<void>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
ack | method | ack(): Promise<void> | Public method; parameters and return type are shown in the signature. |
ackDeadlineAt | property | ackDeadlineAt: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
attempt | property | attempt: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
deadLetter | method | deadLetter(reason: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
deliveryId | property | deliveryId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
envelope | property | envelope: RuntimeMessageEnvelope<TPayload> | Public property; its type, readonly modifier and optionality are shown in the signature. |
extendAckDeadline | method | extendAckDeadline(extensionMs: number): Promise<void> | Public method; parameters and return type are shown in the signature. |
nack | method | nack(options?: { delayMs?: number; reason?: string; }): Promise<void> | Public method; parameters and return type are shown in the signature. |
receivedAt | property | receivedAt: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
MessagePublishRequest
Message Publish Request interface with 1 public fields or methods.
- Kind: interface
- Import:
import type { MessagePublishRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export interface MessagePublishRequest<TPayload = unknown> {
envelope: RuntimeMessageEnvelopeInput<TPayload>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
envelope | property | envelope: RuntimeMessageEnvelopeInput<TPayload> | Public property; its type, readonly modifier and optionality are shown in the signature. |
MessagePublishResult
Message Publish Result interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { MessagePublishResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export interface MessagePublishResult {
messageId: string;
topic: string;
partitionKey: string;
sequence: number;
publishedAt: string;
reused: boolean;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
messageId | property | messageId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
partitionKey | property | partitionKey: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
publishedAt | property | publishedAt: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
reused | property | reused: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
sequence | property | sequence: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
topic | property | topic: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
MessageSubscriptionRequest
Message Subscription Request interface with 8 public fields or methods.
- Kind: interface
- Import:
import type { MessageSubscriptionRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-bus
Declaration
export interface MessageSubscriptionRequest {
consumerId: string;
consumerGroup?: string;
topic: string;
partitionKey?: string;
maxMessages?: number;
idleTimeoutMs?: number;
ackDeadlineMs?: number;
signal?: AbortSignal;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
ackDeadlineMs | property | ackDeadlineMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
consumerGroup | property | consumerGroup?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
consumerId | property | consumerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
idleTimeoutMs | property | idleTimeoutMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxMessages | property | maxMessages?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
partitionKey | property | partitionKey?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
signal | property | signal?: AbortSignal | Public property; its type, readonly modifier and optionality are shown in the signature. |
topic | property | topic: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
