-
-
Notifications
You must be signed in to change notification settings - Fork 301
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
Feature/improves multiple databases support #561
Feature/improves multiple databases support #561
Conversation
Thanks for the work on this! |
It was a pleasure! |
I have just updated to Reverted back to I'm using ORM with different DB to read and write, defined my DB router for read and write, no replica or anything else, here is my setup: Q_CLUSTER = {
'name': 'background_tasks',
'workers': 4,
'timeout': 90,
'daemonize_workers': False,
'retry': 3600,
'compress': True,
'recycle': 100,
'max_rss': 60000,
'save_limit': 0,
'queue_limit': 50,
'bulk': 10,
'orm': 'tasks',
'error_reporter': {
'sentry': {
'dsn': config('SENTRY_DSN')
}
}
} routers.py class Django_Q_Router:
"""
A router to control all database operations on models in the
django_q application.
"""
def db_for_read(self, model, **hints):
"""
Attempts to read django_q models go to tasks.
"""
if model._meta.app_label == 'django_q':
return 'tasks'
return None
def db_for_write(self, model, **hints):
"""
Attempts to write django_q models go to tasks.
"""
if model._meta.app_label == 'django_q':
return 'tasks'
return None
def allow_migrate(self, db, app_label, model_name=None, **hints):
"""
Make sure django_q app only appear in the
'tasks' database, other apps on 'default'.
"""
if app_label == 'django_q':
return db == 'tasks'
else:
return db == 'default' I believe this fixes the problem and ensure the correct way to do this considering all different use cases. |
Improvement related to issue #558.
has_replica
key allowing better multidb support