Skip to content

Commit 70e6955

Browse files
l4mbymagne
andauthored
chore: add jsdoc in publisher and consumer (#249)
Co-authored-by: magne <[email protected]>
1 parent 6ac0eb0 commit 70e6955

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

src/consumer.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,35 @@ export const computeExtendedConsumerId = (consumerId: number, connectionId: stri
1111
}
1212

1313
export interface Consumer {
14+
/**
15+
* Close the publisher
16+
*
17+
* @param {boolean} manuallyClose - Weather you want to close the publisher manually or not
18+
*/
19+
// TODO - clarify the parameter
1420
close(manuallyClose: boolean): Promise<void>
21+
22+
/**
23+
* Store the stream offset on the server
24+
*
25+
* @param {bigint} offsetValue - The value of the offset to save
26+
*/
1527
storeOffset(offsetValue: bigint): Promise<void>
28+
29+
/**
30+
* Get the saved offset on the server
31+
*
32+
* @returns {bigint} The value of the stream offset
33+
*/
1634
queryOffset(): Promise<bigint>
35+
36+
/**
37+
* Gets the infos of the publisher's connection
38+
*
39+
* @returns {ConnectionInfo} Infos on the publisher's connection
40+
*/
1741
getConnectionInfo(): ConnectionInfo
42+
1843
consumerId: number
1944
consumerRef?: string
2045
readonly extendedId: string

src/publisher.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,78 @@ export const computeExtendedPublisherId = (publisherId: number, connectionId: st
7878
}
7979

8080
export interface Publisher {
81+
/**
82+
* Sends a message in the stream
83+
*
84+
* @param {Buffer} message - The encoded content of the message
85+
* @param {MessageOptions} opts - The optional message options and properties
86+
* @returns {SendResult} Returns a boolean value and the associated publishingId
87+
*/
8188
send(message: Buffer, opts?: MessageOptions): Promise<SendResult>
89+
90+
/**
91+
* Sends a message in the stream with a specific publishingId
92+
*
93+
* @param {bigint} publishingId - The associated publishingId
94+
* @param {Buffer} content - The encoded content of the message
95+
* @param {MessageOptions} opts - The optional message options and properties
96+
* @returns {SendResult} Returns a boolean value and the associated publishingId
97+
*/
8298
basicSend(publishingId: bigint, content: Buffer, opts?: MessageOptions): Promise<SendResult>
99+
100+
/**
101+
* Sends all the accumulated messages on the internal buffer
102+
*
103+
* @returns {boolean} Returns false if there was an error
104+
*/
83105
flush(): Promise<boolean>
106+
107+
/**
108+
* Sends a batch of messages
109+
*
110+
* @param {Message[]} messages - A batch of messages to send
111+
* @param {CompressionType} compressionType - Can optionally compress the messages
112+
*/
84113
sendSubEntries(messages: Message[], compressionType?: CompressionType): Promise<void>
114+
115+
/**
116+
* Setup the listener for the metadata update event
117+
*
118+
* @param {"metadata_update"} event - The name of the event
119+
* @param {MetadataUpdateListener} listener - The listener which will be called when the event is fired
120+
*/
85121
on(event: "metadata_update", listener: MetadataUpdateListener): void
122+
123+
/**
124+
* Setup the listener for the publish confirm event
125+
*
126+
* @param {"publish_confirm"} event - The name of the event
127+
* @param {PublishConfirmCallback} listener - The listener which will be called when the event is fired
128+
*/
86129
on(event: "publish_confirm", listener: PublishConfirmCallback): void
130+
131+
/**
132+
* Gets the last publishing id in the stream
133+
*
134+
* @returns {bigint} Last publishing id
135+
*/
87136
getLastPublishingId(): Promise<bigint>
137+
138+
/**
139+
* Gets the infos of the publisher's connection
140+
*
141+
* @returns {ConnectionInfo} Infos on the publisher's connection
142+
*/
88143
getConnectionInfo(): ConnectionInfo
144+
145+
/**
146+
* Close the publisher
147+
*
148+
* @param {boolean} manuallyClose - Weather you want to close the publisher manually or not
149+
*/
150+
// TODO - clarify the parameter
89151
close(manuallyClose: boolean): Promise<void>
152+
90153
closed: boolean
91154
ref: string
92155
readonly publisherId: number

0 commit comments

Comments
 (0)