-
Notifications
You must be signed in to change notification settings - Fork 6
Skip a connection to execute set_config
if the vendor is not postgresql
#9
base: master
Are you sure you want to change the base?
Conversation
Given this package is explicitly for integration with Postgres, could you please elaborate under which conditions the vendor would not be postgresql? |
Easy. Django supports Multiple databases, and one of them could be not Postgres while the one that is used by the package is Postgres. But this hook is executed on every established connection even if that is not related to the package. |
Makes sense. ISTM the better solution, then, would be to find a way to ensure this is only run on the desired database entry. Perhaps an optional setting? |
OK, let me try to find another way how we can achieve this |
Hi @funkybob Please, have a look. The PR is quite heavy right now, but most of it is testing files, they can be removed. The main changes are settings parsing, and I separated settings to make it easier to work with, IMHO. Let me know if you are OK with this approach. |
b92151b
to
2fa3bbf
Compare
3. Add database router in settings.py if you support multiple databases | ||
|
||
.. code-block:: python | ||
|
||
DATABASE_ROUTERS = [ | ||
... | ||
'django_dramatiq_pg.router.Router', | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add this complexity of the router?
Surely the migration itself can check schema_editor.connection
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the router, the migration will be applied to the default alias In the case of multiple database support.
So the router is required in case the DB alias is not "default".
DRAMATIC_BROKER['OPTIONS'] | ||
Arguments to pass to the Broker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you deliberately remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is not necessary anymore because we use the alias to the Django database connection instead of a custom URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you believe it's not possible to want to pass any other options to the Broker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just assumed the intention based on the code and documentation.
Let me go through the available broker options.
pool=None,
url="",
results=True,
schema=None,
table=None,
middleware=None
pool
should be aThreadedConnectionPool
instance that is impossible without additional code just pass as a paramurl
we construct fromDATABASE_ALIAS
schema
andtable
are already hardcoded in the code in theBackgroundJob.Meta.db_table
as default broker values (dramatiq
andqueue
respectively) and previously they were hardcoded asBackgroundJob.Meta.db_table
and literal in the signal handler. So passing the different values would cause the problem without changing the code of the migration and SQL scriptmiddleware
parsed from theMIDDLEWARE
results
is used to configureResults
results middleware withPostgresBackend
. This can be achieved viaMIDDLEWARE
or leftresult=True
as it is.
As the result, the only meaningful and available option for the broker is the results
variable which can be:
- left as is
- placed in a separate variable
- added as separate middleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@funkybob Did I address your concerns?
@funkybob
|
Hi @funkybob |
Hi @funkybob |
No description provided.