Skip to content

Commit

Permalink
Fix/queue params (#385)
Browse files Browse the repository at this point in the history
* fix: healthcheck refactor

* fix: queue params
  • Loading branch information
fenos authored Oct 20, 2023
1 parent 98d5e20 commit ee9457a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,14 @@ export function getConfig(): StorageConfigType {
webhookQueuePullInterval: parseInt(
getOptionalConfigFromEnv('WEBHOOK_QUEUE_PULL_INTERVAL') || '700'
),
webhookQueueTeamSize: parseInt('QUEUE_WEBHOOKS_TEAM_SIZE') || 50,
webhookQueueConcurrency: parseInt('QUEUE_WEBHOOK_CONCURRENCY') || 5,
adminDeleteQueueTeamSize: parseInt('QUEUE_ADMIN_DELETE_TEAM_SIZE') || 50,
adminDeleteConcurrency: parseInt('QUEUE_ADMIN_DELETE_CONCURRENCY') || 5,

webhookQueueTeamSize: parseInt(getOptionalConfigFromEnv('QUEUE_WEBHOOKS_TEAM_SIZE') || '50'),
webhookQueueConcurrency: parseInt(getOptionalConfigFromEnv('QUEUE_WEBHOOK_CONCURRENCY') || '5'),
adminDeleteQueueTeamSize: parseInt(
getOptionalConfigFromEnv('QUEUE_ADMIN_DELETE_TEAM_SIZE') || '50'
),
adminDeleteConcurrency: parseInt(
getOptionalConfigFromEnv('QUEUE_ADMIN_DELETE_CONCURRENCY') || '5'
),
enableImageTransformation: getOptionalConfigFromEnv('ENABLE_IMAGE_TRANSFORMATION') === 'true',
imgProxyRequestTimeout: parseInt(
getOptionalConfigFromEnv('IMGPROXY_REQUEST_TIMEOUT') || '15',
Expand Down
3 changes: 2 additions & 1 deletion src/queue/events/base-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ export abstract class BaseEvent<T extends Omit<BasePayload, '$version'>> {
} catch (e) {
logger.error(
{
error: e,
event: {
type: eventType,
$version: (this as any).version,
applyTime: Date.now(),
payload,
payload: JSON.stringify(payload),
},
tenant: payload.tenant,
},
Expand Down
12 changes: 11 additions & 1 deletion src/queue/events/object-admin-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@ export class ObjectAdminDelete extends BaseEvent<ObjectDeleteEvent> {
withOptionalVersion(s3Key, version) + '.info',
])
} catch (e) {
const s3Key = `${job.data.tenant.ref}/${job.data.bucketId}/${job.data.name}`

logger.error(
{
error: e,
jodId: job.id,
type: 'event',
event: 'ObjectAdminDelete',
payload: JSON.stringify(job.data),
objectPath: s3Key,
tenantId: job.data.tenant.ref,
project: job.data.tenant.ref,
reqId: job.data.reqId,
},
'Error Deleting files from queue'
`[Admin]: ObjectAdminDelete ${s3Key} - FAILED`
)
throw e
}
Expand Down
20 changes: 16 additions & 4 deletions src/queue/events/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ interface WebhookEvent {
event: {
$version: string
type: string
payload: object
payload: object & { reqId?: string }
applyTime: number
}
sentAt: string
traceId?: string
tenant: {
ref: string
host: string
Expand Down Expand Up @@ -55,7 +54,7 @@ export class Webhook extends BaseEvent<WebhookEvent> {
objectPath: path,
tenantId: job.data.tenant.ref,
project: job.data.tenant.ref,
reqId: job.data.traceId,
reqId: job.data.event.payload.reqId,
})

try {
Expand All @@ -74,7 +73,20 @@ export class Webhook extends BaseEvent<WebhookEvent> {
}
)
} catch (e) {
logger.error({ error: e }, 'Webhook failed')
logger.error(
{
error: e,
jodId: job.id,
type: 'event',
event: job.data.event.type,
payload: JSON.stringify(job.data.event.payload),
objectPath: path,
tenantId: job.data.tenant.ref,
project: job.data.tenant.ref,
reqId: job.data.event.payload.reqId,
},
`[Lifecycle]: ${job.data.event.type} ${path} - FAILED`
)
throw e
}

Expand Down

0 comments on commit ee9457a

Please sign in to comment.