oban-bg/oban

Behaviour check in config validation fails with non-standard Repo module

Closed this issue · 3 comments

Environment

  • Oban 2.17

Current Behavior

We're using a non-standard Repo module that conditionally runs proxies to a 'real' Ecto.Repo, or via RPC to a node that has an Ecto.Repo, depending on the region it's in.

When upgrading to Oban 2.17, we get the following exception from the config validation:

** (ArgumentError) expected :repo to implement Ecto.Repo, got: ObanExample.Repo

This makes sense, because ObanExample.Repo does not implement Ecto.Repo behaviour.

Here's an example of the module that handles the proxying:
https://github.com/fly-apps/oban_example/blob/189ee4767d1776c33ac7dced1a97e222e054f766/lib/fly/custom_repo.ex

And the way we'd configure a repo:
https://github.com/fly-apps/oban_example/blob/189ee4767d1776c33ac7dced1a97e222e054f766/lib/oban_example/repo.ex

This all works in 2.16.

Expected Behavior

We have a globally clustered application running on Fly.io, but only some nodes connect to the database directly, remote nodes proxy database requests via RPC to nodes that are connected to the database.

We want to be able to insert jobs from any node (sometimes via RPC) and only process jobs on nodes that are connected to the database.

Nodes that are connected to the database will have a module that does implement Ecto.Repo behaviour, but it'll be proxied from Fly.CustomRepo.

I've tried a couple of things:

  1. Adding Ecto.Repo behaviour to our Fly.CustomRepo module – this doesn't work because it defines callbacks things like start_link, and Fly.CustomRepo is not a process/application.
  2. Using ObanExample.Repo.Local in the config directly. This works on nodes with a repo that is connected to the database, but doesn't work on remote nodes that require an RPC to insert jobs.

@matthewlehner Thanks for the issue! Will you check that the linked commit solves your issue? If so, I'll release a new patch.

@sorentwo it works! Thanks so much!

Excellent! Oban v2.17.2 is out with this fix.