Skip to content

Commit

Permalink
fix: jsdoc (#52)
Browse files Browse the repository at this point in the history
- use correct syntax and existing types
  • Loading branch information
robence authored Aug 21, 2024
1 parent a03e6dc commit 5efbf4f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/Publisher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import QueueMessage from './QueueMessage.js'

/**
* @typedef {import('./QueueConnection')} QueueConnection
* @typedef {import('amqplib').ConfirmChannel} ConfirmChannel
* @typedef {import('amqplib').QueueMessage} QueueMessage
*/

class Publisher {
/**
* @param {QueueConnection} queueConnection
Expand All @@ -24,15 +30,15 @@ class Publisher {
this._assertExchange = assertExchange === true
this._assertExchangeOptions = Object.assign({ durable: true }, assertExchangeOptions)

/** @type {typeof QueueMessage} MessageModel - The class reference for the QueueMessage model. */
this.MessageModel = MessageModel
this.ContentSchema = ContentSchema
}

/**
* Overridden in queueClient to assertQueue instead of exchange
*
* @param channel
* @returns {Promise}
* @param {ConfirmChannel} channel
*/
assertExchangeOrQueue (channel) {
if (this._assertExchange) {
Expand Down
5 changes: 3 additions & 2 deletions src/QueueConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EventEmitter from 'node:events'

/**
* @class QueueConnection
* @extends EventEmitter
* */
class QueueConnection extends EventEmitter {
/**
Expand All @@ -26,7 +27,7 @@ class QueueConnection extends EventEmitter {
}

/**
* @return Promise<amqplib.Connection>
* @returns {Promise<import('amqplib').Connection>}
* */
async connect () {
if (this._connection) {
Expand Down Expand Up @@ -157,7 +158,7 @@ class QueueConnection extends EventEmitter {
}

/**
* @return Promise<amqplib.ConfirmChannel>
* @returns {Promise<import('amqplib').ConfirmChannel>}
* */
async getChannel () {
if (this._channel) {
Expand Down
13 changes: 11 additions & 2 deletions src/RPCClient.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { v4 as uuid } from 'uuid'
import QueueMessage from './QueueMessage.js'

/**
* @typedef {import('./QueueConnection')} QueueConnection
* @typedef {import('./QueueMessage')} QueueMessage
*/

/**
* A queue handler
* @class RPCClient
Expand All @@ -27,6 +32,7 @@ class RPCClient {
exchangeOptions = {}
} = options

/** @type {QueueConnection} */
this._connection = queueConnection
this._logger = logger
this.name = rpcName
Expand All @@ -41,7 +47,9 @@ class RPCClient {

this._rpcQueueMaxSize = queueMaxSize
this._rpcTimeoutMs = timeoutMs
/** @type {typeof QueueMessage} RequestMessageModel - The class reference for the QueueMessage model. */
this.RequestMessageModel = RequestMessageModel
/** @type {typeof QueueMessage} ResponseMessageModel - The class reference for the QueueMessage model. */
this.ResponseMessageModel = ResponseMessageModel
this.RequestContentSchema = RequestContentSchema
this.ResponseContentSchema = ResponseContentSchema
Expand Down Expand Up @@ -105,8 +113,9 @@ class RPCClient {
* @param {Map} attachments
* @param {Boolean} [resolveWithFullResponse=false]
* @param {Object} sendOptions
* @return {Promise<QueueMessage|*>}
* */
* @returns {Promise<QueueMessage|*>}
* @throws {Error}
*/
async call (message, timeoutMs = null, attachments = null, resolveWithFullResponse = false, sendOptions = {}) {
try {
if (this._correlationIdMap.size > this._rpcQueueMaxSize) {
Expand Down

0 comments on commit 5efbf4f

Please sign in to comment.