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

feat(framework) Check TTL when retrieving TaskRes #3635

Merged
merged 61 commits into from
Oct 9, 2024

Conversation

mohammadnaseri
Copy link
Contributor

Description

This PR checks if the corresponding TaskIns exists and remains valid (not expired) when retrieving TaskRes.
Please merge after #3620

@mohammadnaseri mohammadnaseri changed the base branch from main to check-TTL-in-taskins-retrieve September 22, 2024 20:16
Base automatically changed from check-TTL-in-taskins-retrieve to main October 7, 2024 18:07
) or (
node_id is None # Anonymous
and task_ins.task.consumer.anonymous is True
and task_ins.task.consumer.node_id == 0
and task_ins.task.delivered_at == ""
and task_ins.task.created_at + task_ins.task.ttl > time.time()
Copy link
Member

Choose a reason for hiding this comment

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

Let's do the same thing as we did in the previous PR here

task_ins = self.task_ins_store.get(reply_to)
if task_ins is None:
log(ERROR, "TaskIns with task_id %s does not exist.", reply_to)
return []
Copy link
Member

Choose a reason for hiding this comment

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

We should not return [] here. Some of the requested task_ids might have responses and we should return those back to the caller. In the future, we need to introduce a way to return errors for those IDs that are either not existing or expired.


if task_ins.task.created_at + task_ins.task.ttl <= time.time():
log(ERROR, "TaskIns with task_id %s is expired.", reply_to)
return []
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

task_ins = dict_to_task_ins(row)
if task_ins.task.created_at + task_ins.task.ttl <= time.time():
log(ERROR, "TaskIns with task_id %s is expired.", task_ins.task_id)
return []
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

task_id = state.store_task_ins(task_ins=task_ins)

task_res = create_task_res(
producer_node_id=100,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the consumer_node_id of the TaskIns is 1, but the producer_node_id of the replying TaskRes is 100?

task_id = state.store_task_ins(task_ins=task_ins)

task_res = create_task_res(
producer_node_id=100,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above.

Copy link
Contributor

@panh99 panh99 left a comment

Choose a reason for hiding this comment

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

LGTM!

@danieljanes danieljanes merged commit 11f4d72 into main Oct 9, 2024
50 checks passed
@danieljanes danieljanes deleted the check-TTL-in-taskres-retrieve branch October 9, 2024 13:43
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