@codesoul-co/hypha-core / modules/runtime/message-inbox-outbox
- Package index:
@codesoul-co/hypha-core - Source:
packages/core/src/modules/runtime/message-inbox-outbox.ts - Exports: 12
Using this module
Use the Message inbox outbox module for executing runtime behavior at this boundary. It exports 4 classes, 8 interfaces.
Import from the package entrypoint
import {
InMemoryRuntimeMessageInboxStore,
InMemoryRuntimeMessageOutboxStore,
RuntimeInboxProcessor,
RuntimeOutboxDispatcher,
} from '@codesoul-co/hypha-core';
import type {
InboxClaimRequest,
InboxClaimResult,
RuntimeInboxHandleResult,
RuntimeInboxProcessorOptions,
RuntimeMessageInboxStore,
RuntimeMessageOutboxStore,
RuntimeOutboxDispatcherOptions,
RuntimeOutboxDispatchResult,
} from '@codesoul-co/hypha-core';Usage patterns
- Use the 8 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 4 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
InMemoryRuntimeMessageInboxStore | class | new InMemoryRuntimeMessageInboxStore(): InMemoryRuntimeMessageInboxStore | In Memory Runtime Message Inbox Store class with 6 public constructor or member entries; its exact declarations are listed below. |
InMemoryRuntimeMessageOutboxStore | class | new InMemoryRuntimeMessageOutboxStore(): InMemoryRuntimeMessageOutboxStore | In Memory Runtime Message Outbox Store class with 7 public constructor or member entries; its exact declarations are listed below. |
RuntimeInboxProcessor | class | new RuntimeInboxProcessor(options: RuntimeInboxProcessorOptions): RuntimeInboxProcessor | Runtime Inbox Processor class with 2 public constructor or member entries; its exact declarations are listed below. |
RuntimeOutboxDispatcher | class | new RuntimeOutboxDispatcher(options: RuntimeOutboxDispatcherOptions): RuntimeOutboxDispatcher | Runtime Outbox Dispatcher class with 2 public constructor or member entries; its exact declarations are listed below. |
InboxClaimRequest | interface | interface InboxClaimRequest | Inbox Claim Request interface with 7 public fields or methods. |
InboxClaimResult | interface | interface InboxClaimResult | Inbox Claim Result interface with 2 public fields or methods. |
RuntimeInboxHandleResult | interface | interface RuntimeInboxHandleResult | Runtime Inbox Handle Result interface with 3 public fields or methods. |
RuntimeInboxProcessorOptions | interface | interface RuntimeInboxProcessorOptions | Runtime Inbox Processor Options interface with 5 public fields or methods. |
RuntimeMessageInboxStore | interface | interface RuntimeMessageInboxStore | Runtime Message Inbox Store interface with 5 public fields or methods. |
RuntimeMessageOutboxStore | interface | interface RuntimeMessageOutboxStore | Runtime Message Outbox Store interface with 6 public fields or methods. |
RuntimeOutboxDispatcherOptions | interface | interface RuntimeOutboxDispatcherOptions | Runtime Outbox Dispatcher Options interface with 7 public fields or methods. |
RuntimeOutboxDispatchResult | interface | interface RuntimeOutboxDispatchResult | Runtime Outbox Dispatch Result interface with 4 public fields or methods. |
InMemoryRuntimeMessageInboxStore
In Memory Runtime Message Inbox Store class with 6 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { InMemoryRuntimeMessageInboxStore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export declare class InMemoryRuntimeMessageInboxStore implements RuntimeMessageInboxStore {
claim(request: InboxClaimRequest): Promise<InboxClaimResult>;
complete(consumerId: string, messageId: string, ownerId: string, appliedEventIds: string[], completedAt: string): Promise<void>;
fail(consumerId: string, messageId: string, ownerId: string, error: NormalizedRuntimeError, failedAt: string): Promise<void>;
get(consumerId: string, messageId: string): Promise<RuntimeMessageInboxRecord | null>;
health(): Promise<ProviderHealth>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
claim | method | claim(request: InboxClaimRequest): Promise<InboxClaimResult> | Public method; parameters and return type are shown in the signature. |
complete | method | complete(consumerId: string, messageId: string, ownerId: string, appliedEventIds: string[], completedAt: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (): InMemoryRuntimeMessageInboxStore | Creates an instance of this class. |
fail | method | fail(consumerId: string, messageId: string, ownerId: string, error: NormalizedRuntimeError, failedAt: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
get | method | get(consumerId: string, messageId: string): Promise<RuntimeMessageInboxRecord | null> | 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. |
InMemoryRuntimeMessageOutboxStore
In Memory Runtime Message Outbox Store class with 7 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { InMemoryRuntimeMessageOutboxStore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export declare class InMemoryRuntimeMessageOutboxStore implements RuntimeMessageOutboxStore {
enqueue(input: {
id: string;
eventId?: string;
envelope: RuntimeMessageEnvelope;
availableAt?: string;
createdAt: string;
}): Promise<RuntimeMessageOutboxRecord>;
claim(input: {
ownerId: string;
now: string;
leaseMs: number;
limit: number;
}): Promise<RuntimeMessageOutboxRecord[]>;
markPublished(id: string, ownerId: string, publishedAt: string): Promise<void>;
markFailed(input: {
id: string;
ownerId: string;
failedAt: string;
error: NormalizedRuntimeError;
retryAt?: string;
deadLetter?: boolean;
}): Promise<void>;
get(id: string): Promise<RuntimeMessageOutboxRecord | null>;
health(): Promise<ProviderHealth>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
claim | method | claim(input: { ownerId: string; now: string; leaseMs: number; limit: number; }): Promise<RuntimeMessageOutboxRecord[]> | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (): InMemoryRuntimeMessageOutboxStore | Creates an instance of this class. |
enqueue | method | enqueue(input: { id: string; eventId?: string; envelope: RuntimeMessageEnvelope; availableAt?: string; createdAt: string; }): Promise<RuntimeMessageOutboxRecord> | Public method; parameters and return type are shown in the signature. |
get | method | get(id: string): Promise<RuntimeMessageOutboxRecord | null> | 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. |
markFailed | method | markFailed(input: { id: string; ownerId: string; failedAt: string; error: NormalizedRuntimeError; retryAt?: string; deadLetter?: boolean; }): Promise<void> | Public method; parameters and return type are shown in the signature. |
markPublished | method | markPublished(id: string, ownerId: string, publishedAt: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
RuntimeInboxProcessor
Runtime Inbox Processor class with 2 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { RuntimeInboxProcessor } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export declare class RuntimeInboxProcessor {
constructor(options: RuntimeInboxProcessorOptions);
handle(delivery: MessageDelivery, apply: (envelope: RuntimeMessageEnvelope) => Promise<string[]>): Promise<RuntimeInboxHandleResult>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
constructor | constructor | (options: RuntimeInboxProcessorOptions): RuntimeInboxProcessor | Creates an instance of this class. |
handle | method | handle(delivery: MessageDelivery, apply: (envelope: RuntimeMessageEnvelope) => Promise<string[]>): Promise<RuntimeInboxHandleResult> | Public method; parameters and return type are shown in the signature. |
RuntimeOutboxDispatcher
Runtime Outbox Dispatcher class with 2 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { RuntimeOutboxDispatcher } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export declare class RuntimeOutboxDispatcher {
constructor(options: RuntimeOutboxDispatcherOptions);
dispatch(limit?: number): Promise<RuntimeOutboxDispatchResult>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
constructor | constructor | (options: RuntimeOutboxDispatcherOptions): RuntimeOutboxDispatcher | Creates an instance of this class. |
dispatch | method | dispatch(limit?: number): Promise<RuntimeOutboxDispatchResult> | Public method; parameters and return type are shown in the signature. |
InboxClaimRequest
Inbox Claim Request interface with 7 public fields or methods.
- Kind: interface
- Import:
import type { InboxClaimRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface InboxClaimRequest {
consumerId: string;
ownerId: string;
messageId: string;
payloadHash: string;
receivedAt: string;
processingLeaseMs: number;
expiresAt?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
consumerId | property | consumerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
expiresAt | property | expiresAt?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
messageId | property | messageId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
ownerId | property | ownerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
payloadHash | property | payloadHash: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
processingLeaseMs | property | processingLeaseMs: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
receivedAt | property | receivedAt: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
InboxClaimResult
Inbox Claim Result interface with 2 public fields or methods.
- Kind: interface
- Import:
import type { InboxClaimResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface InboxClaimResult {
disposition: 'claimed' | 'duplicate' | 'busy' | 'conflict' | 'expired';
record: RuntimeMessageInboxRecord;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
disposition | property | disposition: "busy" | "expired" | "claimed" | "conflict" | "duplicate" | Public property; its type, readonly modifier and optionality are shown in the signature. |
record | property | record: RuntimeMessageInboxRecord | Public property; its type, readonly modifier and optionality are shown in the signature. |
RuntimeInboxHandleResult
Runtime Inbox Handle Result interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { RuntimeInboxHandleResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface RuntimeInboxHandleResult {
disposition: 'applied' | 'duplicate' | 'busy' | 'failed' | 'dead_lettered' | 'expired';
appliedEventIds: string[];
ackPending?: boolean;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
ackPending | property | ackPending?: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
appliedEventIds | property | appliedEventIds: string[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
disposition | property | disposition: "failed" | "busy" | "expired" | "applied" | "dead_lettered" | "duplicate" | Public property; its type, readonly modifier and optionality are shown in the signature. |
RuntimeInboxProcessorOptions
Runtime Inbox Processor Options interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { RuntimeInboxProcessorOptions } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface RuntimeInboxProcessorOptions {
consumerId: string;
ownerId: string;
inbox: RuntimeMessageInboxStore;
now?: () => string;
processingLeaseMs?: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
consumerId | property | consumerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
inbox | property | inbox: RuntimeMessageInboxStore | 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. |
ownerId | property | ownerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
processingLeaseMs | property | processingLeaseMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
RuntimeMessageInboxStore
Runtime Message Inbox Store interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { RuntimeMessageInboxStore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface RuntimeMessageInboxStore {
claim(request: InboxClaimRequest): Promise<InboxClaimResult>;
complete(consumerId: string, messageId: string, ownerId: string, appliedEventIds: string[], completedAt: string): Promise<void>;
fail(consumerId: string, messageId: string, ownerId: string, error: NormalizedRuntimeError, failedAt: string): Promise<void>;
get(consumerId: string, messageId: string): Promise<RuntimeMessageInboxRecord | null>;
health(): Promise<ProviderHealth>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
claim | method | claim(request: InboxClaimRequest): Promise<InboxClaimResult> | Public method; parameters and return type are shown in the signature. |
complete | method | complete(consumerId: string, messageId: string, ownerId: string, appliedEventIds: string[], completedAt: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
fail | method | fail(consumerId: string, messageId: string, ownerId: string, error: NormalizedRuntimeError, failedAt: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
get | method | get(consumerId: string, messageId: string): Promise<RuntimeMessageInboxRecord | null> | 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. |
RuntimeMessageOutboxStore
Runtime Message Outbox Store interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { RuntimeMessageOutboxStore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface RuntimeMessageOutboxStore {
enqueue(input: {
id: string;
eventId?: string;
envelope: RuntimeMessageEnvelope;
availableAt?: string;
createdAt: string;
}): Promise<RuntimeMessageOutboxRecord>;
claim(input: {
ownerId: string;
now: string;
leaseMs: number;
limit: number;
}): Promise<RuntimeMessageOutboxRecord[]>;
markPublished(id: string, ownerId: string, publishedAt: string): Promise<void>;
markFailed(input: {
id: string;
ownerId: string;
failedAt: string;
error: NormalizedRuntimeError;
retryAt?: string;
deadLetter?: boolean;
}): Promise<void>;
get(id: string): Promise<RuntimeMessageOutboxRecord | null>;
health(): Promise<ProviderHealth>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
claim | method | claim(input: { ownerId: string; now: string; leaseMs: number; limit: number; }): Promise<RuntimeMessageOutboxRecord[]> | Public method; parameters and return type are shown in the signature. |
enqueue | method | enqueue(input: { id: string; eventId?: string; envelope: RuntimeMessageEnvelope; availableAt?: string; createdAt: string; }): Promise<RuntimeMessageOutboxRecord> | Public method; parameters and return type are shown in the signature. |
get | method | get(id: string): Promise<RuntimeMessageOutboxRecord | null> | 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. |
markFailed | method | markFailed(input: { id: string; ownerId: string; failedAt: string; error: NormalizedRuntimeError; retryAt?: string; deadLetter?: boolean; }): Promise<void> | Public method; parameters and return type are shown in the signature. |
markPublished | method | markPublished(id: string, ownerId: string, publishedAt: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
RuntimeOutboxDispatcherOptions
Runtime Outbox Dispatcher Options interface with 7 public fields or methods.
- Kind: interface
- Import:
import type { RuntimeOutboxDispatcherOptions } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface RuntimeOutboxDispatcherOptions {
ownerId: string;
outbox: RuntimeMessageOutboxStore;
bus: MessageBus;
now?: () => string;
leaseMs?: number;
maxAttempts?: number;
retryDelayMs?: (attempt: number) => number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
bus | property | bus: MessageBus | Public property; its type, readonly modifier and optionality are shown in the signature. |
leaseMs | property | leaseMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
maxAttempts | property | maxAttempts?: 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. |
outbox | property | outbox: RuntimeMessageOutboxStore | Public property; its type, readonly modifier and optionality are shown in the signature. |
ownerId | property | ownerId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
retryDelayMs | method | retryDelayMs?(attempt: number): number | Public method; parameters and return type are shown in the signature. |
RuntimeOutboxDispatchResult
Runtime Outbox Dispatch Result interface with 4 public fields or methods.
- Kind: interface
- Import:
import type { RuntimeOutboxDispatchResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/message-inbox-outbox
Declaration
export interface RuntimeOutboxDispatchResult {
claimed: number;
published: number;
failed: number;
deadLettered: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
claimed | property | claimed: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
deadLettered | property | deadLettered: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
failed | property | failed: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
published | property | published: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
