Skip to content

refactor(router): separate worker loop batching logic from processing logic - #6173

Merged
atzoum merged 1 commit into
masterfrom
chore.routerBatchingTests
Jul 25, 2025
Merged

atzoum merged 1 commit into
masterfrom
chore.routerBatchingTests

Conversation

@atzoum

@atzoum atzoum commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor

Description

Refactoring the worker processing logic in the router package to improve code clarity, modularity, and testability.

  • Introducing workerBatchLoop struct in a new file, router/worker_batch_loop.go, to encapsulate batch processing logic. This includes handling job batching, timeouts, and job transformations.
  • Adding tests for the new batch processing logic in router/worker_batch_loop_test.go to ensure correctness.
  • Original worker's workLoop logic is now refactored to use the new workerBatchLoop and we introduced acceptWorkerJob method for managing job filtering and processing, which was previously coupled with batching logic.

Linear Ticket

resolves PIPE-2262

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@atzoum
atzoum force-pushed the chore.routerBatchingTests branch from c28fa2b to 931d530 Compare July 24, 2025 13:53
@atzoum atzoum changed the title refactor(router): split worker loop into smaller loops refactor(router): split worker loop into smaller cohesive loops Jul 24, 2025
@atzoum
atzoum force-pushed the chore.routerBatchingTests branch 2 times, most recently from 7083d86 to 25060e7 Compare July 25, 2025 07:56
@atzoum atzoum changed the title refactor(router): split worker loop into smaller cohesive loops refactor(router): separate worker loop batching logic from processing logic Jul 25, 2025
@atzoum
atzoum force-pushed the chore.routerBatchingTests branch from 25060e7 to aee1967 Compare July 25, 2025 08:06
@atzoum
atzoum force-pushed the chore.routerBatchingTests branch from aee1967 to 643345e Compare July 25, 2025 08:13
@atzoum
atzoum marked this pull request as ready for review July 25, 2025 08:25
@codecov

codecov Bot commented Jul 25, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 91.26016% with 43 lines in your changes missing coverage. Please review.

Project coverage is 76.47%. Comparing base (572422f) to head (643345e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
router/worker.go 90.59% 34 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6173      +/-   ##
==========================================
+ Coverage   76.36%   76.47%   +0.10%     
==========================================
  Files         523      524       +1     
  Lines       70326    70323       -3     
==========================================
+ Hits        53703    53776      +73     
+ Misses      13686    13621      -65     
+ Partials     2937     2926      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@atzoum
atzoum enabled auto-merge (squash) July 25, 2025 10:41
@atzoum
atzoum merged commit af4703d into master Jul 25, 2025
@atzoum
atzoum deleted the chore.routerBatchingTests branch July 25, 2025 11:15
This was referenced Jul 29, 2025
mihir20 pushed a commit that referenced this pull request Jul 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.56.0-rc.1](v1.55.0...v1.56.0-rc.1)
(2025-07-29)


### Features

* change datatype from jsonb to text for warehouse
([#6118](#6118))
([bf90708](bf90708))
* enable lz4 compression for warehouse
([#6119](#6119))
([c8afe87](c8afe87))
* stats for notifier repo module
([#6184](#6184))
([44a0e9f](44a0e9f))
* stats for warehouse repo module
([#6179](#6179))
([07c0391](07c0391))


### Bug Fixes

* add validation to adjustedConversionTime
([#6092](#6092))
([e33bbf9](e33bbf9))
* dangling connection start time not being logged properly
([#6157](#6157))
([965e099](965e099))
* invalidate warehouse schema cache in case of export error
([#6131](#6131))
([c04a953](c04a953))
* load files not being regenerated if schema is outdated
([#6149](#6149))
([0b26aed](0b26aed))
* negative MTU count
([#6180](#6180))
([ecdd64f](ecdd64f))
* **router:** timeout doesn't reset when there are no jobs
([#6171](#6171))
([1e66738](1e66738))
* **router:** worker's batch timeout is getting resetted after new job
arrival
([#6167](#6167))
([1e66738](1e66738))
* schema not being fetched from warehouse for new warehouse destinations
([#6128](#6128))
([6e13cd4](6e13cd4))
* snowpipe events getting duplicated if status API fails
([#6125](#6125))
([2c11854](2c11854))
* update warehouse schema expiry only when fetched from warehouse
([#6130](#6130))
([e0ded8c](e0ded8c))
* **warehouse:** add mutex to mockStageFilesRepo to prevent data race in
tests (WAR-960
([#6156](#6156))
([29c6f01](29c6f01))


### Miscellaneous

* bump the go deps group across 1 directory with 12 updates
([#6178](#6178))
([f57c6e5](f57c6e5))
* clean up processor vars
([#6159](#6159))
([0dbc721](0dbc721))
* cleanup aws v1
([#6113](#6113))
([be1fb41](be1fb41))
* **jobsdb:** introduce context with timeout during add new ds loop
([#6150](#6150))
([1a151c9](1a151c9))
* **jobsdb:** remove foreign key constraint
([#6154](#6154))
([6de673f](6de673f))
* modifications and tests related chagnes for the warehouse lz4 and
jsonb to text conversion
([#6185](#6185))
([a043353](a043353))
* modifications and tests related changes for the notifier lz4 and jsonb
to text conversion
([#6183](#6183))
([918044b](918044b))
* **router:** separate worker loop batching logic from processing logic
([#6173](#6173))
([af4703d](af4703d))
* sync release v1.55.0 to main branch
([#6158](#6158))
([3d2156b](3d2156b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
itsmihir pushed a commit that referenced this pull request Jul 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.56.0-rc.2](v1.55.0...v1.56.0-rc.2)
(2025-07-29)


### Features

* change datatype from jsonb to text for warehouse
([#6118](#6118))
([bf90708](bf90708))
* enable lz4 compression for warehouse
([#6119](#6119))
([c8afe87](c8afe87))
* stats for notifier repo module
([#6184](#6184))
([44a0e9f](44a0e9f))
* stats for warehouse repo module
([#6179](#6179))
([07c0391](07c0391))


### Bug Fixes

* add validation to adjustedConversionTime
([#6092](#6092))
([e33bbf9](e33bbf9))
* dangling connection start time not being logged properly
([#6157](#6157))
([965e099](965e099))
* invalidate warehouse schema cache in case of export error
([#6131](#6131))
([c04a953](c04a953))
* load files not being regenerated if schema is outdated
([#6149](#6149))
([0b26aed](0b26aed))
* negative MTU count
([#6180](#6180))
([ecdd64f](ecdd64f))
* overwrite payloadStage in error response for aborted jobs
([#6193](#6193))
([5d82fa7](5d82fa7))
* **router:** timeout doesn't reset when there are no jobs
([#6171](#6171))
([1e66738](1e66738))
* **router:** worker's batch timeout is getting resetted after new job
arrival
([#6167](#6167))
([1e66738](1e66738))
* schema not being fetched from warehouse for new warehouse destinations
([#6128](#6128))
([6e13cd4](6e13cd4))
* snowpipe events getting duplicated if status API fails
([#6125](#6125))
([2c11854](2c11854))
* update warehouse schema expiry only when fetched from warehouse
([#6130](#6130))
([e0ded8c](e0ded8c))
* **warehouse:** add mutex to mockStageFilesRepo to prevent data race in
tests (WAR-960
([#6156](#6156))
([29c6f01](29c6f01))


### Miscellaneous

* bump the go deps group across 1 directory with 12 updates
([#6178](#6178))
([f57c6e5](f57c6e5))
* clean up processor vars
([#6159](#6159))
([0dbc721](0dbc721))
* cleanup aws v1
([#6113](#6113))
([be1fb41](be1fb41))
* **jobsdb:** introduce context with timeout during add new ds loop
([#6150](#6150))
([1a151c9](1a151c9))
* **jobsdb:** remove foreign key constraint
([#6154](#6154))
([6de673f](6de673f))
* modifications and tests related chagnes for the warehouse lz4 and
jsonb to text conversion
([#6185](#6185))
([a043353](a043353))
* modifications and tests related changes for the notifier lz4 and jsonb
to text conversion
([#6183](#6183))
([918044b](918044b))
* **router:** separate worker loop batching logic from processing logic
([#6173](#6173))
([af4703d](af4703d))
* sync release v1.55.0 to main branch
([#6158](#6158))
([3d2156b](3d2156b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
mihir20 pushed a commit that referenced this pull request Jul 30, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.56.0](v1.55.0...v1.56.0)
(2025-07-29)


### Features

* change datatype from jsonb to text for warehouse
([#6118](#6118))
([bf90708](bf90708))
* enable lz4 compression for warehouse
([#6119](#6119))
([c8afe87](c8afe87))
* stats for notifier repo module
([#6184](#6184))
([44a0e9f](44a0e9f))
* stats for warehouse repo module
([#6179](#6179))
([07c0391](07c0391))


### Bug Fixes

* add validation to adjustedConversionTime
([#6092](#6092))
([e33bbf9](e33bbf9))
* dangling connection start time not being logged properly
([#6157](#6157))
([965e099](965e099))
* invalidate warehouse schema cache in case of export error
([#6131](#6131))
([c04a953](c04a953))
* load files not being regenerated if schema is outdated
([#6149](#6149))
([0b26aed](0b26aed))
* negative MTU count
([#6180](#6180))
([ecdd64f](ecdd64f))
* overwrite payloadStage in error response for aborted jobs
([#6193](#6193))
([5d82fa7](5d82fa7))
* **router:** timeout doesn't reset when there are no jobs
([#6171](#6171))
([1e66738](1e66738))
* **router:** worker's batch timeout is getting resetted after new job
arrival
([#6167](#6167))
([1e66738](1e66738))
* schema not being fetched from warehouse for new warehouse destinations
([#6128](#6128))
([6e13cd4](6e13cd4))
* snowpipe events getting duplicated if status API fails
([#6125](#6125))
([2c11854](2c11854))
* update warehouse schema expiry only when fetched from warehouse
([#6130](#6130))
([e0ded8c](e0ded8c))
* **warehouse:** add mutex to mockStageFilesRepo to prevent data race in
tests (WAR-960
([#6156](#6156))
([29c6f01](29c6f01))


### Miscellaneous

* bump the go deps group across 1 directory with 12 updates
([#6178](#6178))
([f57c6e5](f57c6e5))
* clean up processor vars
([#6159](#6159))
([0dbc721](0dbc721))
* cleanup aws v1
([#6113](#6113))
([be1fb41](be1fb41))
* **jobsdb:** introduce context with timeout during add new ds loop
([#6150](#6150))
([1a151c9](1a151c9))
* **jobsdb:** remove foreign key constraint
([#6154](#6154))
([6de673f](6de673f))
* modifications and tests related chagnes for the warehouse lz4 and
jsonb to text conversion
([#6185](#6185))
([a043353](a043353))
* modifications and tests related changes for the notifier lz4 and jsonb
to text conversion
([#6183](#6183))
([918044b](918044b))
* **router:** separate worker loop batching logic from processing logic
([#6173](#6173))
([af4703d](af4703d))
* sync release v1.55.0 to main branch
([#6158](#6158))
([3d2156b](3d2156b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants