@@ -30,7 +30,9 @@ export class UpdateMetadataService extends BaseService {
3030
3131 constructor (
3232 protected readonly _prisma : PrismaClientOrTransaction = prisma ,
33- private readonly flushIntervalMs : number = 5000
33+ private readonly flushIntervalMs : number = 5000 ,
34+ private readonly flushEnabled : boolean = true ,
35+ private readonly flushLoggingEnabled : boolean = true
3436 ) {
3537 super ( ) ;
3638
@@ -39,6 +41,14 @@ export class UpdateMetadataService extends BaseService {
3941
4042 // Start a loop that periodically flushes buffered operations
4143 private _startFlushing ( ) {
44+ if ( ! this . flushEnabled ) {
45+ logger . info ( "[UpdateMetadataService] 🚽 Flushing disabled" ) ;
46+
47+ return ;
48+ }
49+
50+ logger . info ( "[UpdateMetadataService] 🚽 Flushing started" ) ;
51+
4252 // Create a program that sleeps, then processes buffered ops
4353 const program = Effect . gen ( this , function * ( _ ) {
4454 while ( true ) {
@@ -50,9 +60,11 @@ export class UpdateMetadataService extends BaseService {
5060 this . _bufferedOperations . clear ( ) ;
5161
5262 yield * Effect . sync ( ( ) => {
53- logger . debug ( `[UpdateMetadataService] Flushing operations` , {
54- operations : Object . fromEntries ( currentOperations ) ,
55- } ) ;
63+ if ( this . flushLoggingEnabled ) {
64+ logger . debug ( `[UpdateMetadataService] Flushing operations` , {
65+ operations : Object . fromEntries ( currentOperations ) ,
66+ } ) ;
67+ }
5668 } ) ;
5769
5870 // If we have operations, process them
@@ -87,10 +99,12 @@ export class UpdateMetadataService extends BaseService {
8799 }
88100
89101 yield * Effect . sync ( ( ) => {
90- logger . debug ( `[UpdateMetadataService] Processing operations for run` , {
91- runId,
92- operationsCount : processedOps . length ,
93- } ) ;
102+ if ( this . flushLoggingEnabled ) {
103+ logger . debug ( `[UpdateMetadataService] Processing operations for run` , {
104+ runId,
105+ operationsCount : processedOps . length ,
106+ } ) ;
107+ }
94108 } ) ;
95109
96110 // Update run with retry
@@ -410,5 +424,11 @@ export class UpdateMetadataService extends BaseService {
410424
411425export const updateMetadataService = singleton (
412426 "update-metadata-service" ,
413- ( ) => new UpdateMetadataService ( prisma , env . BATCH_METADATA_OPERATIONS_FLUSH_INTERVAL_MS )
427+ ( ) =>
428+ new UpdateMetadataService (
429+ prisma ,
430+ env . BATCH_METADATA_OPERATIONS_FLUSH_INTERVAL_MS ,
431+ env . BATCH_METADATA_OPERATIONS_FLUSH_ENABLED === "1" ,
432+ env . BATCH_METADATA_OPERATIONS_FLUSH_LOGGING_ENABLED === "1"
433+ )
414434) ;
0 commit comments