RealOrangeOne / django-tasks

A reference implementation and backport of background workers and tasks in Django
https://pypi.org/project/django-tasks/
BSD 3-Clause "New" or "Revised" License
314 stars 22 forks source link

Specify which database backend to use #38

Open RealOrangeOne opened 3 months ago

RealOrangeOne commented 3 months ago

It's currently not possible to specify which database backend will be used (ie the ones configured in DATABASES). Especially for SQLite, it's useful to separate the queue tables into a separate database.

turingnixstyx commented 2 months ago

Hey is this still open and unassigned?

RealOrangeOne commented 2 months ago

Yes. If you're interested in working on it, by all means do. I don't assign issues to people specifically though - anyone can work on anything.

fazeelghafoor commented 2 months ago

@RealOrangeOne if this needs to be implemented, can we just add database in the following tasks config if we are using DatabaseBackend and set the default to default database defined in settings and then have all task related models to use the database defined in tasks config dict.

TASKS = {
    "default": {
        "BACKEND": "django_tasks.backends.immediate.ImmediateBackend",
        "DATABASE": "name_of_the_database" i.e. "tasks_db" # if not set use the default
    }
}

or are we looking for a more sophisticated solution than this option.

RealOrangeOne commented 2 months ago

I think it'll need something a little more complex than this, as both the worker and migrations need to use this value. It might be that a database router is the only way to implement this, in which case there's not much to do ourselves besides ensure the correct DB is specified when needed.