Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of parsing job body format according to the job id version #225

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

git-hulk
Copy link
Member

Currently, we store the job payload in Redis without any encoding,
so it's possible to extend more fields for a job, like attributes, etc.

To mitigate this issue, we introduce the version prefix for the job id
to identify different job payload formats. Use the length to tell
if it's a legacy id or not since the ulid's id is a fixed-length
string(26 chars). That said, we will return the value as job body
directly if the length is 26. Otherwise, decode it in JSON format.

Also, to avoid introducing breaking changes during the upgrade stage,
we add a new HTTP header: Enable-Job-Version to enable this feature.
The new job format would be enabled only if the header Enable-Job-Version: yes
was explicitly passed in the publish request. So that we can smoothly
support the new job payload format by upgrading the server first, and enabling
it on client side since then.

Currently, we store the job payload in Redis without any encoding,
so it's possible to extend more fields for job, like attributes etc.

To mitigate this issue, we introduce the version prefix for the job id
to identify different job payload formats. And use the length to tell
if it's a legacy id or not since the ulid's id is a fixed length
string(26 chars). That said, we will return the value as job body
directly if the length is 26. Otherwise, decode it as JSON format.

And to avoid introducing breaking changes during the upgrade stage,
we add a new HTTP header: Enable-Job-Version to enable this feature.
The new job format would be enabled only if the header `Enable-Job-Version: yes`
was explicitly passed in the publish request. So that we can smoothly
support new job payload format by upgrading the server first, and enable
it in client side since then.
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 54.16667% with 22 lines in your changes missing coverage. Please review.

Project coverage is 51.84%. Comparing base (8d3282e) to head (af53fbe).
Report is 3 commits behind head on master.

Files Patch % Lines
engine/redis/pool.go 52.38% 6 Missing and 4 partials ⚠️
uuid/uuid.go 35.71% 6 Missing and 3 partials ⚠️
server/handlers/queue.go 76.92% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #225      +/-   ##
==========================================
- Coverage   56.23%   51.84%   -4.40%     
==========================================
  Files          38       25      -13     
  Lines        2984     1846    -1138     
==========================================
- Hits         1678      957     -721     
+ Misses       1090      746     -344     
+ Partials      216      143      -73     
Flag Coverage Δ
unittests 51.84% <54.16%> (-4.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@Lance726 Lance726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@git-hulk git-hulk enabled auto-merge (squash) July 10, 2024 09:37
@git-hulk git-hulk disabled auto-merge July 10, 2024 09:37
@git-hulk git-hulk merged commit bc3b3a1 into master Jul 10, 2024
7 of 9 checks passed
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.

None yet

2 participants