Skip to content

Feature/deferred task correlation #120

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 2 commits into from
Jan 23, 2023
Merged

Conversation

dshafer
Copy link
Collaborator

@dshafer dshafer commented Jan 19, 2023

  • Update CHANGELOG.md
  • Update README.md (as needed)
  • New dependencies were added to pyproject.toml
  • pip install succeeds with a clean virtualenv
  • There are new or modified tests that cover changes
  • Test coverage is maintained or expanded

@salesforce-cla
Copy link

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Drew Shafer <a***@.s.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce.com Contributor License Agreement and this Pull Request will be revalidated.

@dshafer dshafer force-pushed the feature/deferred-task-correlation-id branch from 2d577ba to 135a747 Compare January 19, 2023 17:10
tasks._set_correlation_id = set_correlation_id
tasks._get_correlation_id = lambda: "cid-sentinel"
try:

Copy link
Collaborator

Choose a reason for hiding this comment

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

💄 extra blank line

@@ -820,6 +820,39 @@ def setUp(self):
"filtered_retry_count_2": 0,
}

def test_future_task_runner_sets_cid(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a test covering when cid is not present?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

basically every existing test is checking that condition

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good. Thanks!

@dshafer dshafer force-pushed the feature/deferred-task-correlation-id branch from 135a747 to 9bdad90 Compare January 19, 2023 17:26
smholloway
smholloway previously approved these changes Jan 19, 2023
@@ -151,6 +153,9 @@ def future_task_runner(
resource_instance = resource_class.objects.get(pk=resource_instance_id)
endpoint_task = getattr(endpoint_class, endpoint_method_name)

if correlation_id:
Copy link
Member

Choose a reason for hiding this comment

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

Is this guard needed? Shouldn't it be set to None if not set? If it's not Noned, wouldn't a set value leak into the next task because it's stored in thread locals?

update correlation_id if cid module installed

Fixes #119
@dshafer dshafer force-pushed the feature/deferred-task-correlation-id branch from 9bdad90 to 21dcb6e Compare January 19, 2023 19:07
@bgrant
Copy link
Collaborator

bgrant commented Jan 20, 2023

Can you add a CHANGELOG entry @dshafer ?

@@ -26,8 +26,10 @@
import cid.locals
Copy link
Collaborator

@bgrant bgrant Jan 20, 2023

Choose a reason for hiding this comment

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

Since we use it in testing, should we add django-cid to our optional-dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we're actually mocking it in testing, so it's not necessary. What's the rule for putting things in optional-dependencies? It doesn't seem to simplify installing things with pip

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh- maybe you overload the necessary method in testing. I'm trying to think about where, if anywhere, django-cid should go in our listed dependencies in pyproject.toml. Maybe nowhere, and (ideally) we would just document that DDA supports it somewhere (README or docs). That doesn't need to be in this PR.

@bgrant bgrant self-requested a review January 23, 2023 17:50
Copy link
Collaborator

@bgrant bgrant left a comment

Choose a reason for hiding this comment

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

LGTM!

@dshafer dshafer merged commit 6040669 into main Jan 23, 2023
@dshafer dshafer deleted the feature/deferred-task-correlation-id branch January 23, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants