Skip to content

Commit

Permalink
Concert TrackContentUploadManager to typescript (#4251)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaylor89 committed Nov 2, 2022
1 parent cc676ef commit 6fa72ca
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 159 deletions.
7 changes: 4 additions & 3 deletions creator-node/src/AsyncProcessingQueue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Job } from 'bullmq'
import type { Request } from 'express'
import type { SpanContext } from '@opentelemetry/api'
import type { LogContext } from './apiHelpers'

import { Queue, Worker } from 'bullmq'
import { logger } from './logging'
Expand Down Expand Up @@ -41,7 +42,7 @@ export const ProcessStates = {
} as const

type AddTaskParams = {
logContext: { requestID: string }
logContext: LogContext
task: string
req: Request
parentSpanContext?: SpanContext
Expand Down Expand Up @@ -95,7 +96,7 @@ export class AsyncProcessingQueue {
]
: [],
attributes: {
requestID: logContext.requestID,
requestID: logContext.requestId,
[tracing.CODE_FILEPATH]: __filename
}
}
Expand Down Expand Up @@ -250,7 +251,7 @@ export class AsyncProcessingQueue {
async monitorProgress(
task: string,
func: (...args: any) => any,
{ logContext, req }: { logContext: any; req: Request }
{ logContext, req }: { logContext: LogContext; req: Request }
) {
const uuid = logContext.requestID
const redisKey = this.constructAsyncProcessingKey(uuid)
Expand Down
7 changes: 4 additions & 3 deletions creator-node/src/ImageProcessingQueue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { PrometheusRegistry } from './services/prometheusMonitoring/prometheusRegistry'
import type { ValuesOf } from './utils'
import type { LogContext } from './apiHelpers'

import { Queue, QueueEvents, Worker } from 'bullmq'
import path from 'path'
Expand Down Expand Up @@ -74,10 +75,10 @@ export class ImageProcessingQueue {

/**
* Logs a status message and includes current queue info
* @param {object} logContext to create a logger.child(logContext) from
* @param {LogContext} logContext to create a logger.child(logContext) from
* @param {string} message
*/
async logStatus(logContext: Object, message: string) {
async logStatus(logContext: LogContext, message: string) {
const logger = genericLogger.child(logContext)
const count = await this.queue.count()
logger.info(`Image Processing Queue (count ${count}): ${message}`)
Expand Down Expand Up @@ -118,7 +119,7 @@ export class ImageProcessingQueue {
fileName: string
sizes: Record<string, number>
square: boolean
logContext: Object
logContext: LogContext
}) {
const job = await this.queue.add(ProcessNames.resizeImage, {
file,
Expand Down
4 changes: 2 additions & 2 deletions creator-node/src/TranscodingQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TranscodingQueue {
* @param {string} fileDir
* @param {string} fileName
* @param {Object} logContext to create a logger.child(logContext) from
* @returns {Object} response in the structure
* @returns response in the structure
{
segments: {
fileNames: segmentFileNames {string[]}: the segment file names only,
Expand Down Expand Up @@ -194,7 +194,7 @@ class TranscodingQueue {
* @param {string} fileDir
* @param {string} fileName
* @param {Object} logContext to create a logger.child(logContext) from
* @returns {Object} { transcodeFilePath {string}: where the transcode exists in the fs }
* @returns { transcodeFilePath {string}: where the transcode exists in the fs }
*/
async transcode320(fileDir, fileName, { logContext }) {
this.logStatus(
Expand Down
4 changes: 4 additions & 0 deletions creator-node/src/apiHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export type CustomRequest = Request & {
normalizedPath?: string
}

export type LogContext = {
requestID: string
}

type ApiResponse = {
statusCode: number
object: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { SpanContext } from '@opentelemetry/api'
import type { LogContext } from '../../apiHelpers'

/**
* Enqueues sync operation into syncQueue for provided walletPublicKeys against provided creatorNodeEndpoint
Expand All @@ -18,7 +19,7 @@ export const enqueueSync = async (params: {
wallet: string
}
forceWipe: boolean
logContext: Object
logContext: LogContext
parentSpanContext: SpanContext
serviceRegistry: any
}) => {
Expand All @@ -45,7 +46,7 @@ export const processManualImmediateSync = async (params: {
wallet: string
}
forceWipe: boolean
logContext: Object
logContext: LogContext
parentSpanContext: SpanContext
serviceRegistry: any
}) => {
Expand Down

0 comments on commit 6fa72ca

Please sign in to comment.