44 * Continuously polls the metadata store for pending jobs
55 * that need transformation, then runs the appropriate transformer.
66 */
7-
8- import { PlatformType } from '@crowd/types'
9- import { getServiceChildLogger } from '@crowd/logging'
10- import { getDbConnection , WRITE_DB_CONFIG } from '@crowd/database'
11- import { QueueFactory , QUEUE_CONFIG } from '@crowd/queue'
12- import { getRedisClient , REDIS_CONFIG , RedisCache } from '@crowd/redis'
137import { DataSinkWorkerEmitter } from '@crowd/common_services'
8+ import { WRITE_DB_CONFIG , getDbConnection } from '@crowd/database'
9+ import { getServiceChildLogger } from '@crowd/logging'
10+ import { QUEUE_CONFIG , QueueFactory } from '@crowd/queue'
11+ import { REDIS_CONFIG , RedisCache , getRedisClient } from '@crowd/redis'
12+ import { PlatformType } from '@crowd/types'
1413
14+ import { IntegrationResolver } from '../core/integrationResolver'
1515import { MetadataStore , SnowflakeExportJob } from '../core/metadataStore'
1616import { S3Consumer } from '../core/s3Consumer'
17- import { IntegrationResolver } from '../core/integrationResolver'
18- import { getPlatform , getEnabledPlatforms } from '../integrations'
17+ import { getEnabledPlatforms , getPlatform } from '../integrations'
1918
2019const log = getServiceChildLogger ( 'transformerConsumer' )
2120
@@ -56,9 +55,15 @@ export class TransformerConsumer {
5655 continue
5756 }
5857
59- log . info ( { currentPollingIntervalMs : this . currentPollingIntervalMs } , 'No pending jobs, backing off' )
58+ log . info (
59+ { currentPollingIntervalMs : this . currentPollingIntervalMs } ,
60+ 'No pending jobs, backing off' ,
61+ )
6062 await this . sleep ( this . currentPollingIntervalMs )
61- this . currentPollingIntervalMs = Math . min ( this . currentPollingIntervalMs * 2 , MAX_POLLING_INTERVAL_MS )
63+ this . currentPollingIntervalMs = Math . min (
64+ this . currentPollingIntervalMs * 2 ,
65+ MAX_POLLING_INTERVAL_MS ,
66+ )
6267 }
6368
6469 log . info ( 'Transformer consumer stopped' )
@@ -97,7 +102,11 @@ export class TransformerConsumer {
97102 continue
98103 }
99104
100- await this . emitter . createAndProcessActivityResult ( resolved . segmentId , resolved . integrationId , result . activity )
105+ await this . emitter . createAndProcessActivityResult (
106+ resolved . segmentId ,
107+ resolved . integrationId ,
108+ result . activity ,
109+ )
101110 transformedCount ++
102111 }
103112
@@ -115,7 +124,9 @@ export class TransformerConsumer {
115124 log . error ( { jobId : job . id , err } , 'Job failed' )
116125
117126 try {
118- await this . metadataStore . markFailed ( job . id , errorMessage , { processingDurationMs : Date . now ( ) - startTime } )
127+ await this . metadataStore . markFailed ( job . id , errorMessage , {
128+ processingDurationMs : Date . now ( ) - startTime ,
129+ } )
119130 } catch ( updateErr ) {
120131 log . error ( { jobId : job . id , updateErr } , 'Failed to mark job as failed' )
121132 }
0 commit comments