generated from MapColonies/ts-server-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added polling jobs status system (#31)
* feat: added polling jobs status system * fix: lint errors * fix: main poll loop * fix: pr issues * fix: pr issues * test: added task manager unit test * test: added and fixed unit-tests * fix: mc-priority-queue version & tests * fix: tests * fix: spelling + lint error
- Loading branch information
1 parent
786bccc
commit 11960f1
Showing
31 changed files
with
865 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { inject, singleton } from 'tsyringe'; | ||
import { HttpClient, IHttpRetryConfig } from '@map-colonies/mc-utils'; | ||
import { Logger } from '@map-colonies/js-logger'; | ||
import { SERVICES } from '../common/constants'; | ||
import { ICallbackData, IConfig } from '../common/interfaces'; | ||
|
||
@singleton() | ||
export class CallbackClient extends HttpClient { | ||
public constructor(@inject(SERVICES.LOGGER) logger: Logger, @inject(SERVICES.CONFIG) private readonly config: IConfig) { | ||
super(logger, '', 'requestCallback', config.get<IHttpRetryConfig>('httpRetry')); | ||
} | ||
|
||
public async send(callbackUrl: string, params: ICallbackData): Promise<void> { | ||
this.logger.info(`send Callback request to URL: ${callbackUrl} with data ${JSON.stringify(params)}`); | ||
await this.post(callbackUrl, params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { promises as fsPromise } from 'fs'; | ||
import { join } from 'path'; | ||
import { BBox } from '@turf/turf'; | ||
|
||
export const getFileSize = async (filePath: string): Promise<number> => { | ||
const fileSizeInBytes = (await fsPromise.stat(filePath)).size; | ||
return Math.trunc(fileSizeInBytes); // Make sure we return an Integer | ||
}; | ||
|
||
export const generatePackageName = (dbId: string, zoomLevel: number, bbox: BBox): string => { | ||
const numberOfDecimals = 5; | ||
const bboxToString = bbox.map((val) => String(val.toFixed(numberOfDecimals)).replace('.', '_').replace(/-/g, 'm')).join(''); | ||
return `gm_${dbId.replace(/-/g, '_')}_${zoomLevel}_${bboxToString}.gpkg`; | ||
}; | ||
|
||
export const getGpkgRelativePath = (packageName: string): string => { | ||
const packageDirectoryName = packageName.substr(0, packageName.lastIndexOf('.')); | ||
const packageRelativePath = join(packageDirectoryName, packageName); | ||
return packageRelativePath; | ||
}; | ||
|
||
export const getGpkgFullPath = (gpkgsLocation: string, packageName: string): string => { | ||
const packageDirectoryName = packageName.substr(0, packageName.lastIndexOf('.')); | ||
const packageFullPath = join(gpkgsLocation, packageDirectoryName, packageName); | ||
return packageFullPath; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.