diff --git a/src/consumer.ts b/src/consumer.ts index 8fc85bc..d410e19 100644 --- a/src/consumer.ts +++ b/src/consumer.ts @@ -11,10 +11,35 @@ export const computeExtendedConsumerId = (consumerId: number, connectionId: stri } export interface Consumer { + /** + * Close the publisher + * + * @param {boolean} manuallyClose - Weather you want to close the publisher manually or not + */ + // TODO - clarify the parameter close(manuallyClose: boolean): Promise + + /** + * Store the stream offset on the server + * + * @param {bigint} offsetValue - The value of the offset to save + */ storeOffset(offsetValue: bigint): Promise + + /** + * Get the saved offset on the server + * + * @returns {bigint} The value of the stream offset + */ queryOffset(): Promise + + /** + * Gets the infos of the publisher's connection + * + * @returns {ConnectionInfo} Infos on the publisher's connection + */ getConnectionInfo(): ConnectionInfo + consumerId: number consumerRef?: string readonly extendedId: string diff --git a/src/publisher.ts b/src/publisher.ts index 5bc283d..66665ff 100644 --- a/src/publisher.ts +++ b/src/publisher.ts @@ -78,15 +78,78 @@ export const computeExtendedPublisherId = (publisherId: number, connectionId: st } export interface Publisher { + /** + * Sends a message in the stream + * + * @param {Buffer} message - The encoded content of the message + * @param {MessageOptions} opts - The optional message options and properties + * @returns {SendResult} Returns a boolean value and the associated publishingId + */ send(message: Buffer, opts?: MessageOptions): Promise + + /** + * Sends a message in the stream with a specific publishingId + * + * @param {bigint} publishingId - The associated publishingId + * @param {Buffer} content - The encoded content of the message + * @param {MessageOptions} opts - The optional message options and properties + * @returns {SendResult} Returns a boolean value and the associated publishingId + */ basicSend(publishingId: bigint, content: Buffer, opts?: MessageOptions): Promise + + /** + * Sends all the accumulated messages on the internal buffer + * + * @returns {boolean} Returns false if there was an error + */ flush(): Promise + + /** + * Sends a batch of messages + * + * @param {Message[]} messages - A batch of messages to send + * @param {CompressionType} compressionType - Can optionally compress the messages + */ sendSubEntries(messages: Message[], compressionType?: CompressionType): Promise + + /** + * Setup the listener for the metadata update event + * + * @param {"metadata_update"} event - The name of the event + * @param {MetadataUpdateListener} listener - The listener which will be called when the event is fired + */ on(event: "metadata_update", listener: MetadataUpdateListener): void + + /** + * Setup the listener for the publish confirm event + * + * @param {"publish_confirm"} event - The name of the event + * @param {PublishConfirmCallback} listener - The listener which will be called when the event is fired + */ on(event: "publish_confirm", listener: PublishConfirmCallback): void + + /** + * Gets the last publishing id in the stream + * + * @returns {bigint} Last publishing id + */ getLastPublishingId(): Promise + + /** + * Gets the infos of the publisher's connection + * + * @returns {ConnectionInfo} Infos on the publisher's connection + */ getConnectionInfo(): ConnectionInfo + + /** + * Close the publisher + * + * @param {boolean} manuallyClose - Weather you want to close the publisher manually or not + */ + // TODO - clarify the parameter close(manuallyClose: boolean): Promise + closed: boolean ref: string readonly publisherId: number