ProcessRegistry
Overview
Section titled “Overview”ProcessRegistry is the index the bus uses to look up which process manager (saga) should run for an inbound message. It tracks three things: the set of registered data-type names, the process-name to data-type mapping, and the per-message-type list of ProcessRegistration entries flagged as either start or continue.
Most users do not construct or call methods on ProcessRegistry directly. The fluent DSL on the bus is the canonical API:
bus .registerProcessData<OrderState>('OrderState') .registerProcess('OrderProcess', { dataType: 'OrderState', store }) .startsWith('OrderPlaced', new OnOrderPlaced()) .handles('OrderPaid', new OnOrderPaid());The registry is exposed via bus.processRegistry for inspection — tests, diagnostics, and tooling that needs to enumerate registered processes.
Import
Section titled “Import”import { ProcessRegistry } from '@serviceconnect/core';ProcessRegistration is not exported from the package barrel. Its shape, for
reference:
interface ProcessRegistration { readonly processName: string; readonly dataType: string; readonly messageType: string; readonly isStart: boolean; readonly handler: ProcessHandler<ProcessData, Message>; readonly store?: ISagaStore; // per-process saga store readonly timeoutStore?: ITimeoutStore; // per-process timeout store}Signature
Section titled “Signature”export class ProcessRegistry { registerDataType(dataType: string): void; isDataTypeRegistered(dataType: string): boolean; lastRegisteredDataType(): string | undefined;
registerProcess( processName: string, options: { dataType: string; store?: ISagaStore; timeoutStore?: ITimeoutStore }, ): void;
hasAny(): boolean; distinctTimeoutStores(): readonly ITimeoutStore[];
startsWith<TData extends ProcessData, TMessage extends Message>( processName: string, messageType: string, handler: ProcessHandler<TData, TMessage>, ): void;
handles<TData extends ProcessData, TMessage extends Message>( processName: string, messageType: string, handler: ProcessHandler<TData, TMessage>, ): void;
registrationsFor(messageType: string): readonly ProcessRegistration[]; allMessageTypes(): readonly string[]; processDataType(processName: string): string | undefined;}Members
Section titled “Members”registerDataType(dataType)— declare a saga data type name. Forwarded frombus.registerProcessData. Records the value and remembers it as the most-recent data type so subsequentregisterProcesscalls can bind to it implicitly.isDataTypeRegistered(dataType)—trueifdataTypewas previously declared viaregisterDataType. Used byregisterProcessto fail fast if you forget the data-type declaration.lastRegisteredDataType()— the most recent value passed toregisterDataType, orundefinedif none has been declared. The fluent bus DSL uses this whenregisterProcessis called without an explicitdataTypeoption.registerProcess(processName, options)— register a process manager underprocessName, bound tooptions.dataType. ThrowsInvalidOperationErrorif the data type was not previously declared. Optionally accepts a per-processstore?: ISagaStoreandtimeoutStore?: ITimeoutStoreto bind this process to dedicated saga and timeout stores instead of the bus-wide defaults.hasAny()—trueif at least one process is registered. The bus consults this duringstart()to decide whether to wire the saga branch.distinctTimeoutStores()— the unique-by-reference set ofITimeoutStoreinstances across all registered processes. The bus starts oneTimeoutPollerper distinct store.startsWith(processName, messageType, handler)— bindhandleras a saga-starting handler formessageType. The bus invokes this handler with a fresh saga-state object when no row exists for the correlation id.handles(processName, messageType, handler)— bindhandleras a continue handler formessageType. The bus only invokes this handler when a saga row already exists for the correlation id.registrationsFor(messageType)— list everyProcessRegistration(across all processes) that fires formessageType. Returns an empty array when no process is interested in that type.allMessageTypes()— every message-type name some process has registered against. The bus uses this to add subscriptions on the consumer.processDataType(processName)— the data-type name a previously-registered process was bound to, orundefinedifprocessNamewas never registered.