Skip to content

Commit

Permalink
fix(doc): refactor js doc to reflect global logger
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerni10 committed Nov 28, 2022
1 parent cac7366 commit a994998
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions src/service/cache/archive.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ARCHIVE_FOLDER = 'archive'
class ArchiveService {
/**
* @param {String} northId - The North ID connector
* @param {LoggerService} loggerService - The logger
* @param {Object} logger - The logger
* @param {String} baseFolder - The North cache folder generated as north-connectorId. This base folder can
* be in data-stream or history-query folder depending on the connector use case
* @param {Boolean} enabled - If the archive mode for this North connector is enabled
Expand All @@ -23,13 +23,13 @@ class ArchiveService {
*/
constructor(
northId,
loggerService,
logger,
baseFolder,
enabled,
retentionDuration,
) {
this.northId = northId
this.loggerService = loggerService
this.logger = logger
this.baseFolder = baseFolder
this.enabled = enabled
// Convert from hours to ms to compare with mtimeMs (file modified time in ms)
Expand Down Expand Up @@ -72,17 +72,17 @@ class ArchiveService {
// Move cache file into the archive folder
try {
await fs.rename(filePathInCache, archivePath)
this.loggerService.debug(`File "${filePathInCache}" moved to "${archivePath}".`)
this.logger.debug(`File "${filePathInCache}" moved to "${archivePath}".`)
} catch (renameError) {
this.loggerService.error(renameError)
this.logger.error(renameError)
}
} else {
// Delete original file
try {
await fs.unlink(filePathInCache)
this.loggerService.debug(`File "${filePathInCache}" removed from disk.`)
this.logger.debug(`File "${filePathInCache}" removed from disk.`)
} catch (unlinkError) {
this.loggerService.error(unlinkError)
this.logger.error(unlinkError)
}
}
}
Expand All @@ -92,7 +92,7 @@ class ArchiveService {
* @return {void}
*/
async refreshArchiveFolder() {
this.loggerService.debug('Parse archive folder to remove old files.')
this.logger.debug('Parse archive folder to remove old files.')
// If a timeout already runs, clear it
if (this.archiveTimeout) {
clearTimeout(this.archiveTimeout)
Expand All @@ -103,7 +103,7 @@ class ArchiveService {
files = await fs.readdir(this.archiveFolder)
} catch (error) {
// If the archive folder doest not exist (removed by the user for example), an error is logged
this.loggerService.error(error)
this.logger.error(error)
}
if (files.length > 0) {
const referenceDate = new Date().getTime()
Expand All @@ -113,7 +113,7 @@ class ArchiveService {
async () => this.removeFileIfTooOld(file, referenceDate, this.archiveFolder),
), Promise.resolve())
} else {
this.loggerService.debug(`The archive folder "${this.archiveFolder}" is empty. Nothing to delete.`)
this.logger.debug(`The archive folder "${this.archiveFolder}" is empty. Nothing to delete.`)
}
this.archiveTimeout = setTimeout(this.refreshArchiveFolder.bind(this), ARCHIVE_TIMEOUT)
}
Expand All @@ -131,14 +131,14 @@ class ArchiveService {
// If a file is being written or corrupted, the stat method can fail an error is logged
stats = await fs.stat(path.join(archiveFolder, filename))
} catch (error) {
this.loggerService.error(error)
this.logger.error(error)
}
if (stats && stats.mtimeMs + this.retentionDuration < referenceDate) {
try {
await fs.unlink(path.join(archiveFolder, filename))
this.loggerService.debug(`File "${path.join(archiveFolder, filename)}" removed from archive.`)
this.logger.debug(`File "${path.join(archiveFolder, filename)}" removed from archive.`)
} catch (unlinkError) {
this.loggerService.error(unlinkError)
this.logger.error(unlinkError)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/service/cache/file-cache.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ERROR_FOLDER = 'files-errors'
class FileCacheService {
/**
* @param {String} northId - The North ID connector
* @param {Logger} logger - The logger
* @param {Object} logger - The logger
* @param {String} baseFolder - The North cache folder generated as north-connectorId. This base folder can
* be in data-stream or history-query folder depending on the connector use case
@param {Function} northSendFilesCallback - Method used by the North to handle values
Expand Down Expand Up @@ -361,7 +361,7 @@ class FileCacheService {
if (filenames.length > 0) {
await this.removeErrorFiles(filenames)
} else {
this.logger.debug(`The archive folder "${this.archiveFolder}" is empty. Nothing to delete.`)
this.logger.debug(`The error folder "${this.errorFolder}" is empty. Nothing to delete.`)
}
}

Expand All @@ -374,7 +374,7 @@ class FileCacheService {
if (filenames.length > 0) {
await this.retryErrorFiles(filenames)
} else {
this.logger.debug(`The archive folder "${this.archiveFolder}" is empty. Nothing to delete.`)
this.logger.debug(`The error folder "${this.errorFolder}" is empty. Nothing to delete.`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/cache/value-cache.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ERROR_FOLDER = 'values-errors'
class ValueCacheService {
/**
* @param {String} northId - The North ID connector
* @param {LoggerService} logger - The logger
* @param {Object} logger - The logger
* @param {String} baseFolder - The North cache folder generated as north-connectorId. This base folder can
* be in data-stream or history-query folder depending on the connector use case
* @param {Function} northSendValuesCallback - Method used by the North to handle values
Expand Down

0 comments on commit a994998

Please sign in to comment.