@@ -59,7 +59,13 @@ export type RunsReplicationServiceOptions = {
5959 insertMaxDelayMs ?: number ;
6060} ;
6161
62- type TaskRunInsert = { _version : bigint ; run : TaskRun ; event : "insert" | "update" | "delete" } ;
62+ type PostgresTaskRun = TaskRun & { masterQueue : string } ;
63+
64+ type TaskRunInsert = {
65+ _version : bigint ;
66+ run : PostgresTaskRun ;
67+ event : "insert" | "update" | "delete" ;
68+ } ;
6369
6470export type RunsReplicationServiceEvents = {
6571 message : [ { lsn : string ; message : PgoutputMessage ; service : RunsReplicationService } ] ;
@@ -243,7 +249,7 @@ export class RunsReplicationService {
243249 }
244250 }
245251
246- async backfill ( runs : TaskRun [ ] ) {
252+ async backfill ( runs : PostgresTaskRun [ ] ) {
247253 // divide into batches of 50 to get data from Postgres
248254 const flushId = nanoid ( ) ;
249255 // Use current timestamp as LSN (high enough to be above existing data)
@@ -352,7 +358,7 @@ export class RunsReplicationService {
352358 const replicationLagMs = Date . now ( ) - Number ( message . commitTime / 1000n ) ;
353359 this . _currentTransaction . commitEndLsn = message . commitEndLsn ;
354360 this . _currentTransaction . replicationLagMs = replicationLagMs ;
355- const transaction = this . _currentTransaction as Transaction < TaskRun > ;
361+ const transaction = this . _currentTransaction as Transaction < PostgresTaskRun > ;
356362 this . _currentTransaction = null ;
357363
358364 if ( transaction . commitEndLsn ) {
@@ -370,7 +376,7 @@ export class RunsReplicationService {
370376 }
371377 }
372378
373- #handleTransaction( transaction : Transaction < TaskRun > ) {
379+ #handleTransaction( transaction : Transaction < PostgresTaskRun > ) {
374380 if ( this . _isShutDownComplete ) return ;
375381
376382 if ( this . _isShuttingDown ) {
@@ -764,7 +770,7 @@ export class RunsReplicationService {
764770 }
765771
766772 async #prepareTaskRunInsert(
767- run : TaskRun ,
773+ run : PostgresTaskRun ,
768774 organizationId : string ,
769775 environmentType : string ,
770776 event : "insert" | "update" | "delete" ,
@@ -814,6 +820,7 @@ export class RunsReplicationService {
814820 output,
815821 concurrency_key : run . concurrencyKey ?? "" ,
816822 bulk_action_group_ids : run . bulkActionGroupIds ?? [ ] ,
823+ worker_queue : run . masterQueue ,
817824 _version : _version . toString ( ) ,
818825 _is_deleted : event === "delete" ? 1 : 0 ,
819826 } ;
0 commit comments