-
Notifications
You must be signed in to change notification settings - Fork 7
process async with polling, no message limit #252
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
8391dd1
add traffic calculator
Ian-Nara 2f426ad
update from review
Ian-Nara 7d18fbd
add unit tests
Ian-Nara 726feda
allow custom eval window
Ian-Nara 1d8f050
update comment
Ian-Nara 4bc5e45
switch to configmap for traffic config
Ian-Nara 72a99d0
update to all k8s
Ian-Nara 027f576
update config validations
Ian-Nara 58bd298
small rename
Ian-Nara b3cbdfd
test fix
Ian-Nara a802e31
undo accidental change
Ian-Nara e26a64f
whitespace
Ian-Nara fd13b69
whitespace
Ian-Nara 14a6c1f
update traffic baseline to hardcoded
Ian-Nara 843f41f
naming improvements
Ian-Nara 1477e2f
naming improvements
Ian-Nara d75bc0d
naming improvements
Ian-Nara d7db764
small comment/name update
Ian-Nara a178540
naming update
Ian-Nara df7ab91
naming update
Ian-Nara ac2a613
process async with polling, no message limit
Ian-Nara 38c86b3
add newest delta file logic
Ian-Nara 160c5de
Merge branch 'ian-UID2-6337-asynchronous-full-queue-process' into ian…
Ian-Nara 962b7cc
update comments
Ian-Nara 16dfe53
add traffic filter
Ian-Nara 21bfda3
merge in some message info stuff
Ian-Nara b520a7a
Merge branch 'ian-UID2-6337-asynchronous-full-queue-process' into ian…
Ian-Nara 51d4a87
config names
Ian-Nara b7116f9
Merge branch 'ian-UID2-6337-asynchronous-full-queue-process' into ian…
Ian-Nara 6f4cf76
merge
Ian-Nara 458d70a
Merge branch 'ian-UID2-6146-update-traffic-calculator-to-hardcoded-ba…
Ian-Nara 127703a
limit messages per delta file for memory protection
Ian-Nara 2873ea2
imrpove naminig / comment
Ian-Nara f6b7f46
update traffic calculator
Ian-Nara a93b051
address comments
Ian-Nara 019f426
undo accidental commit
Ian-Nara 0265ae2
Merge branch 'ian-UID2-6337-asynchronous-full-queue-process' into ian…
Ian-Nara f671dd4
Merge branch 'ian-UID2-6146-update-traffic-calculator-to-hardcoded-ba…
Ian-Nara 47f63b0
Merge branch 'main' into ian-UID2-6337-asynchronous-full-queue-process
Ian-Nara 213eb5f
Merge branch 'ian-UID2-6337-asynchronous-full-queue-process' into ian…
Ian-Nara 64f1e61
Merge branch 'ian-UID2-6146-update-traffic-calculator-to-hardcoded-ba…
Ian-Nara 8531ec5
Merge pull request #253 from IABTechLab/ian-UID2-6151-add-traffic-fil…
Ian-Nara 4388f1b
Merge pull request #251 from IABTechLab/ian-UID2-6146-update-traffic-…
Ian-Nara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/com/uid2/optout/vertx/DeltaProduceJobStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| package com.uid2.optout.vertx; | ||
|
|
||
| import io.vertx.core.json.JsonObject; | ||
| import java.time.Instant; | ||
|
|
||
| /** | ||
| * Represents the status and result of an async delta production job on a pod. | ||
| * | ||
| * This class tracks the lifecycle of a delta production job including its state | ||
| * (running, completed, failed), timing information, and result or error details. | ||
| * | ||
| */ | ||
| public class DeltaProduceJobStatus { | ||
| private final Instant startTime; | ||
| private volatile JobState state; | ||
| private volatile JsonObject result; | ||
| private volatile String errorMessage; | ||
| private volatile Instant endTime; | ||
|
|
||
| public enum JobState { | ||
| RUNNING, | ||
| COMPLETED, | ||
| FAILED | ||
| } | ||
|
|
||
| public DeltaProduceJobStatus() { | ||
| this.startTime = Instant.now(); | ||
| this.state = JobState.RUNNING; | ||
| } | ||
|
|
||
| /** | ||
| * Mark the job as completed with the given result. | ||
| * @param result The result details as a JsonObject | ||
| */ | ||
| public void complete(JsonObject result) { | ||
| this.result = result; | ||
| this.state = JobState.COMPLETED; | ||
| this.endTime = Instant.now(); | ||
| } | ||
|
|
||
| /** | ||
| * Mark the job as failed with the given error message. | ||
| * @param errorMessage Description of the failure | ||
| */ | ||
| public void fail(String errorMessage) { | ||
| this.errorMessage = errorMessage; | ||
| this.state = JobState.FAILED; | ||
| this.endTime = Instant.now(); | ||
| } | ||
|
|
||
| /** | ||
| * Get the current state of the job. | ||
| * @return The job state | ||
| */ | ||
| public JobState getState() { | ||
| return state; | ||
| } | ||
|
|
||
| /** | ||
| * Convert the job status to a JSON representation for API responses. | ||
| * @return JsonObject with state, timing, and result/error information | ||
| */ | ||
| public JsonObject toJson() { | ||
| JsonObject json = new JsonObject() | ||
| .put("state", state.name().toLowerCase()) | ||
| .put("start_time", startTime.toString()); | ||
|
|
||
| if (endTime != null) { | ||
| json.put("end_time", endTime.toString()); | ||
| long durationSeconds = endTime.getEpochSecond() - startTime.getEpochSecond(); | ||
| json.put("duration_seconds", durationSeconds); | ||
| } | ||
|
|
||
| if (state == JobState.COMPLETED && result != null) { | ||
| json.put("result", result); | ||
| } | ||
|
|
||
| if (state == JobState.FAILED && errorMessage != null) { | ||
| json.put("error", errorMessage); | ||
| } | ||
|
|
||
| return json; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why volatile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State is read from the event loop thread and is written from the (single possible) worker thread caused by execute blocking.
The event loop just reads the status occasionally; the worker thread can write to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
job.encode() to send the response is in the status handler, and job.complete(result) is in the blocking, worker thread code.