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

DJANGO_DRAMATIQ_TASKS_NOT_WRITES, DJANGO_DRAMATIQ_TASKS_WRITES_ONLY #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ikvk
Copy link

@ikvk ikvk commented Apr 27, 2024

Allow to specify which actors to write to the database with "black" and "white" lists:

DJANGO_DRAMATIQ_TASKS_NOT_WRITES = ['actor_name_that_excluded']
DJANGO_DRAMATIQ_TASKS_WRITES_ONLY = ['actor_name_that_writes_only1', 'actor_name_that_writes_only2'

Copy link
Collaborator

@andrewgy8 andrewgy8 left a comment

Choose a reason for hiding this comment

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

Hey @ikvk ! Thanks for another contribution! Would you mind opening an issue related to this so we can properly track the feature?

Thanks so much!


class TaskManager(models.Manager):
def create_or_update_from_message(self, message, **extra_fields):
def create_or_update_from_message(self, message, **extra_fields) -> Optional['Task']:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick:

Suggested change
def create_or_update_from_message(self, message, **extra_fields) -> Optional['Task']:
def create_or_update_from_message(self, message, **extra_fields):

I dont believe we are using types in this project. Can you please remove this for consistency? 😄

Copy link
Author

Choose a reason for hiding this comment

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

I suggest adding types everywhere, it always makes it easier to read the code. Compatibility will not be affected: in the library "Requirements Python 3.9+"

def create_or_update_from_message(self, message, **extra_fields) -> Optional['Task']:

# black and write lists
if DJANGO_DRAMATIQ_TASKS_WRITES_ONLY and message.actor_name not in DJANGO_DRAMATIQ_TASKS_WRITES_ONLY:
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: Since you default to an empty list in the getattr method above, the first part of this conditional should not be necessary.

Suggested change
if DJANGO_DRAMATIQ_TASKS_WRITES_ONLY and message.actor_name not in DJANGO_DRAMATIQ_TASKS_WRITES_ONLY:
if message.actor_name not in DJANGO_DRAMATIQ_TASKS_WRITES_ONLY:

Copy link
Author

@ikvk ikvk Dec 28, 2024

Choose a reason for hiding this comment

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

False-like vals will not works this way. For example - None

def create_or_update_from_message(self, message, **extra_fields):
def create_or_update_from_message(self, message, **extra_fields) -> Optional['Task']:

# black and write lists
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick:

Suggested change
# black and write lists

Copy link
Author

Choose a reason for hiding this comment

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

okay

@ikvk
Copy link
Author

ikvk commented Dec 28, 2024

Would you mind opening an issue related to this so we can properly track the feature?

#171

Done

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.

2 participants