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

Replace local names with registry #331

Merged
merged 21 commits into from
Sep 13, 2020

Conversation

sasa1977
Copy link
Contributor

This replaces locally registered names with Registry based names, which allows us to use arbitrary terms as oban instance names, e.g. {Oban, name: {:tenant, 1}}. This is the preparation for supporting running dynamic Oban instances which can work with dynamic Ecto repos, as discussed in #326.

In terms of function signatures, the change should be backwards compatible. However, if the client code relied on the previous name registration, it will break.

Summary of changes:

  • Oban now has its own supervision tree with a registry which is used for process discovery.
  • Any term can be used as name. Note that name still has to be unique, i.e. it's not possible to start two instances with the same name.
  • Configuration is also managed in the registry.
  • To improve confidence, integration tests are adapted to use a unique non-atom name.
  • Name is also used as the default child id in Oban.child_spec.

Copy link
Member

@sorentwo sorentwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this amazing work. The global registry, storing config, using the name as the id automatically, and the dramatically improved isolation guarantees are brilliant.

I've left some nitpicks, nearly all of which are in the name of consistency and to satisfy my neurosis. This is a great start to a v2.2.0 🎉

lib/oban.ex Show resolved Hide resolved
lib/oban.ex Outdated Show resolved Hide resolved
lib/oban.ex Show resolved Hide resolved
lib/oban.ex Outdated Show resolved Hide resolved
lib/oban/application.ex Outdated Show resolved Hide resolved
@@ -12,33 +12,33 @@ defmodule Oban.Integration.ControllingTest do
end

test "starting individual queues dynamically" do
start_supervised_oban!(queues: [alpha: 10])
name = start_supervised_oban!(queues: [alpha: 10]).name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The look of this may take me some getting used to. The fact that it is a unique reference for every test is fantastic though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully it's a bit simpler now, after I applied your proposal of only returning the name.

test/test_helper.exs Outdated Show resolved Hide resolved
test/test_helper.exs Outdated Show resolved Hide resolved
Comment on lines +121 to +125
multi = Multi.new()
multi = Oban.insert(context.name, multi, :job_1, UniqueWorker.new(%{id: 1}))
multi = Oban.insert(context.name, multi, :job_2, UniqueWorker.new(%{id: 2}))
multi = Oban.insert(context.name, multi, :job_3, UniqueWorker.new(%{id: 1}))
assert {:ok, %{job_1: job_1, job_2: job_2, job_3: job_3}} = Repo.transaction(multi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a shame, this was a nice pipe chain 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can I say. You win some, you lose some :-)

test/integration/isolation_test.exs Outdated Show resolved Hide resolved
@sasa1977
Copy link
Contributor Author

I think I addressed everything. Let me know if something else is needed.

@sorentwo sorentwo merged commit 0e026b5 into oban-bg:master Sep 13, 2020
@sorentwo
Copy link
Member

That was everything. This is exciting stuff, puno hvala! 💛

@sasa1977 sasa1977 deleted the replace-local-names-with-registry branch September 30, 2020 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants