@@ -30,7 +30,9 @@ export class UpdateMetadataService extends BaseService {
30
30
31
31
constructor (
32
32
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
34
36
) {
35
37
super ( ) ;
36
38
@@ -39,6 +41,14 @@ export class UpdateMetadataService extends BaseService {
39
41
40
42
// Start a loop that periodically flushes buffered operations
41
43
private _startFlushing ( ) {
44
+ if ( ! this . flushEnabled ) {
45
+ logger . info ( "[UpdateMetadataService] 🚽 Flushing disabled" ) ;
46
+
47
+ return ;
48
+ }
49
+
50
+ logger . info ( "[UpdateMetadataService] 🚽 Flushing started" ) ;
51
+
42
52
// Create a program that sleeps, then processes buffered ops
43
53
const program = Effect . gen ( this , function * ( _ ) {
44
54
while ( true ) {
@@ -50,9 +60,11 @@ export class UpdateMetadataService extends BaseService {
50
60
this . _bufferedOperations . clear ( ) ;
51
61
52
62
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
+ }
56
68
} ) ;
57
69
58
70
// If we have operations, process them
@@ -87,10 +99,12 @@ export class UpdateMetadataService extends BaseService {
87
99
}
88
100
89
101
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
+ }
94
108
} ) ;
95
109
96
110
// Update run with retry
@@ -410,5 +424,11 @@ export class UpdateMetadataService extends BaseService {
410
424
411
425
export const updateMetadataService = singleton (
412
426
"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
+ )
414
434
) ;
0 commit comments