UNPKG

@ydbjs/topic

Version:

YDB Topics client for publish-subscribe messaging. Provides at-least-once delivery, exactly-once publishing, FIFO guarantees, and scalable message processing for unstructured data.

82 lines 2.6 kB
import type { Driver } from "@ydbjs/core"; import type { ActorRef, CallbackSnapshot } from "xstate"; import type { CompressionCodec } from "../codec.js"; import type { TX } from "../tx.js"; import type { WriterStreamEmittedEvent, WriterStreamInput, WriterStreamReceiveEvent } from "./stream.ts"; import type { YDBDebugLogger } from "@ydbjs/debug"; export type TopicWriterOptions = { tx?: TX; topic: string; codec?: CompressionCodec; producerId: string; partitionId?: bigint; messageGroupId?: string; maxBufferBytes?: bigint; maxInflightCount?: number; flushIntervalMs?: number; updateTokenIntervalMs?: number; gracefulShutdownTimeoutMs?: number; garbageCollection?: { maxGarbageCount?: number; maxGarbageSize?: bigint; forceGC?: boolean; }; }; export type WriterContext = { readonly dbg: YDBDebugLogger; readonly tx?: TX; readonly driver: Driver; readonly options: TopicWriterOptions; readonly attempts: number; readonly producerId: string; readonly partitionId?: bigint; readonly messageGroupId?: string; readonly sessionId?: string; readonly messages: import("@ydbjs/api/topic").StreamWriteMessage_WriteRequest_MessageData[]; readonly bufferStart: number; readonly bufferLength: number; readonly inflightStart: number; readonly inflightLength: number; readonly bufferSize: bigint; readonly inflightSize: bigint; readonly garbageSize: bigint; readonly lastError?: unknown; readonly streamRef?: ActorRef<CallbackSnapshot<WriterStreamInput>, WriterStreamReceiveEvent, WriterStreamEmittedEvent> | undefined; }; export type MessageToSend = { data: Uint8Array; seqNo: bigint; createdAt?: Date; metadataItems?: Record<string, Uint8Array>; }; export type WriterEvents = { type: 'writer.write'; message: MessageToSend; } | { type: 'writer.flush'; } | { type: 'writer.close'; } | { type: 'writer.destroy'; reason?: unknown; } | WriterStreamEmittedEvent; export type WriterEmitted = { type: 'writer.error'; error: unknown; } | { type: 'writer.close'; reason?: unknown; } | { type: 'writer.session'; sessionId: string; lastSeqNo: bigint; } | { type: 'writer.acknowledgments'; acknowledgments: Map<bigint, 'skipped' | 'written' | 'writtenInTx'>; }; export type WriterInput = { driver: Driver; options: TopicWriterOptions; }; export type WriterStates = 'connecting' | 'connected' | 'errored' | 'writing' | 'flushing' | 'closing' | 'destroyed'; //# sourceMappingURL=types.d.ts.map