Bogdanp / django_dramatiq

A Django app that integrates with Dramatiq.
https://dramatiq.io
Other
331 stars 77 forks source link

Recommendation to separate jobs for different "envs" #141

Open stripedpumpkin opened 1 year ago

stripedpumpkin commented 1 year ago

Hello. We have django app for which we have "django envs" which can be though of as Rails envs. This allows us to run the app locally against various databases (among other things). We would like to run dramatiq on at least two of these (local) envs, using a local redis instance as both broker and backend. We would like to avoid having these two envs colliding. One idea that came to mind was to do something like:

DRAMATIQ_BROKER = {
    "BROKER": "dramatiq.brokers.redis.RedisBroker",
    "OPTIONS": {
        "url": "redis://localhost:6379",
        'db': env.int('RQ_LOCAL_REDIS_DB_SLOT'),
    },

(we have a separate setting config file for each env, essentially mimicking what happens in Rails.)

and using a different redis db for each env, but we are using the various dbs for other apps (typically sidekiq) and this seems like a suboptimal solution.

Is there a natural (or at least recommended) way to isolate the jobs coming from separate envs (and maybe results as well) ?

Thanks for reading