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

Add Oban generator to phx.new #5970

Closed
wants to merge 4 commits into from

Conversation

sorentwo
Copy link
Contributor

@sorentwo sorentwo commented Nov 9, 2024

This adds Oban by default to phx.new with the following considerations:

  • It uses the facade approach, e.g. use Oban, to generate a dedicated MyApp.Oban module for the application. This makes configuration in the application clearer and more familiar, because it matches MyApp.Repo. This would also allow multiple apps in an umbrella to have their own Oban instances without any name conflicts.
  • It automatically selects the correct engine for Postgres or SQLite3. Creating a new project with other, currently unsupported, databases won't include Oban. This is documented in the task help.
  • Configured with a single default queue, a pruning plugin set to retain jobs for one hour, and an empty crontab to indicate that periodic jobs are available.
  • A default migration that will create the necessary oban tables.
  • Configuration for testing as well as test helpers included in DataCase.

Questions

  • Is the facade (MyApp.Oban) approach alright with others? It's newer, and officially supported for several versions now, but it isn't what the installation docs prescribe.
  • The migration is generated with the number 0, rather than a timestamp just to get it working. Any thoughts or suggestions on how to get the correctly named file, or whether a different hard-coded number may work?
  • This only adds minimal documentation, and it feels sparse, esp. without some concrete examples. Thoughts?
  • There isn't support for the umbrella generator yet. I can add that once we've decided on a direction here.

It Works!

Here's a screenshot after running mix phx.new my_app; mix ecto.reset; iex -S mix phx.server and checking that Oban is up and running:

Screenshot 2024-11-09 at 17 03 56

@SteffenDE
Copy link
Contributor

I am a big fan of Oban (also using Oban Pro at work), but I’m not sure how far we should go with including external libraries in the official generators, as those integrations need to be maintained. Maybe it would be better to improve extending the generators from external packages? There could be a mix oban.phx.new or mix phx.new --plugin oban (where the oban hex package would need to provide a specific module).

@sorentwo
Copy link
Contributor Author

After some reflection, and some outside advice, I don't think this is a good fit. Oban shouldn't be in every Phoenix app, especially not by default. Aside from the slippery slope of "what belongs in Phoenix by default", there's too much separate education necessary to use it and understand what it is doing.

Now that I've gone through the exercise of seeing all the touch points, I'll revisit a simplified igniter based installer instead.

@sorentwo sorentwo closed this Nov 10, 2024
@sorentwo
Copy link
Contributor Author

Maybe it would be better to improve extending the generators from external packages? There could be a mix oban.phx.new or mix phx.new --plugin oban (where the oban hex package would need to provide a specific module).

That's a nice idea. Making it possibly to auto-install commonly used packages seems helpful.

@sorentwo sorentwo deleted the oban-installer branch November 11, 2024 17:14
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