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

Set flag in query options to detect oban query #687

Closed
SteffenDE opened this issue Apr 13, 2022 · 1 comment
Closed

Set flag in query options to detect oban query #687

SteffenDE opened this issue Apr 13, 2022 · 1 comment
Labels
area:oss Related to Oban OSS closed:wontfix This will not be worked on kind:enhancement New feature or request

Comments

@SteffenDE
Copy link

Is your feature request related to a problem? Please describe.

We're using multi tenancy like in the following Ecto documentation: https://hexdocs.pm/ecto/multi-tenancy-with-foreign-keys.html
and we have the problem that oban queries fail as the repo expected org_id or skip_org_id to be set. For migrations there is a check for :schema_migration, but as far as I can see oban queries can currently only be detected by looking into the :telemetry_options.

Describe the Solution You'd Like

I'd imagine oban setting a flag like :oban to true for oban queries (probably here). Adding a note to the documentation about this use case would be great.

Describe Alternatives You've Considered

I tried adding a new repo module only for oban, but this is clumsy and seems to cause ecto sandbox errors when running tests.

Additional Context

Currently, I check for opts[:schema_migration] || get_in(opts, [:telemetry_options, :oban]) which works, but could probably break in the future.

@sorentwo
Copy link
Owner

Oban's Repo is a light wrapper around Ecto.Repo, and we're limited to the options that it supports. While Ecto.Repo might ignore an oban: true option now, they could be stricter about the options in a future release, and I don't want to break all of Oban's queries.

On the other hand, telemetry_options is officially supported to inject metadata into queries, and it's already used by Oban (as you noted.) You're safe to keep checking for a schema migration or in telemetry_options. Our use of telemetry_options is here to stay, but it could use some documentation.

@sorentwo sorentwo added kind:enhancement New feature or request closed:wontfix This will not be worked on area:oss Related to Oban OSS labels Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:oss Related to Oban OSS closed:wontfix This will not be worked on kind:enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants