Skip to content

Commit

Permalink
chore(deps): setup :oban (#351)
Browse files Browse the repository at this point in the history
Gladear authored Jan 15, 2025
1 parent b077053 commit 27fbf8e
Showing 7 changed files with 53 additions and 15 deletions.
5 changes: 2 additions & 3 deletions apps/app/lib/app/application.ex
Original file line number Diff line number Diff line change
@@ -17,9 +17,8 @@ defmodule App.Application do
# Start the PubSub system
{Phoenix.PubSub, name: App.PubSub},
# Start Finch
{Finch, name: Swoosh.Finch}
# Start a worker by calling: App.Worker.start_link(arg)
# {App.Worker, arg}
{Finch, name: Swoosh.Finch},
{Oban, Application.fetch_env!(:app, Oban)}
]

Supervisor.start_link(children, strategy: :one_for_one, name: App.Supervisor)
3 changes: 3 additions & 0 deletions apps/app/mix.exs
Original file line number Diff line number Diff line change
@@ -56,6 +56,9 @@ defmodule App.MixProject do
{:gen_smtp, "~> 1.2"},
{:finch, "~> 0.18"},

# Job scheduler
{:oban, "~> 2.18"},

# Code analysis
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule App.Repo.Migrations.AddObanJobsTable do
use Ecto.Migration

def up do
Oban.Migration.up(version: 12)
end

# We specify `version: 1` in `down`, ensuring that we'll roll all the way back down if
# necessary, regardless of which version we've migrated `up` to.
def down do
Oban.Migration.down(version: 1)
end
end
12 changes: 0 additions & 12 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -81,18 +81,6 @@ config :phoenix, :json_library, Jason
config :gettext, :default_locale, "en"
config :ex_cldr, default_backend: AppWeb.Cldr, default_locale: "en"

# ## Error reporting
#
# Configure the Sentry SDK. Requires to call `plug Sentry.PlugContext`
# in the Endpoint.
#
# See the documentation of `:sentry` for more information.

config :sentry,
client: Sentry.FinchClient,
enable_source_code_context: true,
root_source_code_path: File.cwd!()

# ## Storybook
#
# The Storybook is disabled by default, only enabled in `:dev` environment.
31 changes: 31 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
@@ -96,3 +96,34 @@ if config_env() == :prod do
secret: ses_secret_key,
identity: ses_identity
end

# ## Oban

config :app, Oban,
engine: Oban.Engines.Basic,
repo: App.Repo,
queues: [default: 10],
plugins: [
{Oban.Plugins.Pruner, max_age: 60 * 60 * 24 * 30},
{Oban.Plugins.Lifeline, rescue_after: to_timeout(minute: 30)}
]

# ## Monitoring

## Sentry
#
# Configure the Sentry SDK. Requires to call `plug Sentry.PlugContext`
# in the Endpoint.
#
# See the documentation of `:sentry` for more information.

config :sentry,
client: Sentry.FinchClient,
enable_source_code_context: true,
root_source_code_path: File.cwd!(),
integrations: [
oban: [
capture_errors: true,
cron: [enabled: true]
]
]
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ config :app, App.Vault,
iv_length: 12}
]

# Prevent Oban from automatically running jobs and plugins during test runs
config :app, Oban, testing: :manual

# We don't run a server during test. If one is required,
# you can enable the server option below.
config :app_web, AppWeb.Endpoint,
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@
"nimble_ownership": {:hex, :nimble_ownership, "1.0.1", "f69fae0cdd451b1614364013544e66e4f5d25f36a2056a9698b793305c5aa3a6", [:mix], [], "hexpm", "3825e461025464f519f3f3e4a1f9b68c47dc151369611629ad08b636b73bb22d"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
"oban": {:hex, :oban, "2.18.3", "1608c04f8856c108555c379f2f56bc0759149d35fa9d3b825cb8a6769f8ae926", [:mix], [{:ecto_sql, "~> 3.10", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "36ca6ca84ef6518f9c2c759ea88efd438a3c81d667ba23b02b062a0aa785475e"},
"phoenix": {:hex, :phoenix, "1.7.18", "5310c21443514be44ed93c422e15870aef254cf1b3619e4f91538e7529d2b2e4", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "1797fcc82108442a66f2c77a643a62980f342bfeb63d6c9a515ab8294870004e"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.6.3", "f686701b0499a07f2e3b122d84d52ff8a31f5def386e03706c916f6feddf69ef", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "909502956916a657a197f94cc1206d9a65247538de8a5e186f7537c895d95764"},
"phoenix_html": {:hex, :phoenix_html, "4.2.0", "83a4d351b66f472ebcce242e4ae48af1b781866f00ef0eb34c15030d4e2069ac", [:mix], [], "hexpm", "9713b3f238d07043583a94296cc4bbdceacd3b3a6c74667f4df13971e7866ec8"},

0 comments on commit 27fbf8e

Please sign in to comment.