Skip to content

Commit

Permalink
Merge pull request #4500 from santiment/add-oban-web-to-admin-pod
Browse files Browse the repository at this point in the history
Add oban web to admin pod
  • Loading branch information
tspenov authored Dec 15, 2024
2 parents 65bb29d + 84e2a3d commit 266d243
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ config :sanbase, Oban.Web,
],
name: :oban_web

config :sanbase, Oban.Admin,
repo: Sanbase.Repo,
queues: [],
name: :oban_admin

config :nostrum,
token: {:system, "DISCORD_BOT_QUERY_TOKEN"},
gateway_intents: [
Expand Down
3 changes: 2 additions & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ config :phoenix,
# Disable the Oban.Web jobs in local env.
# When testing Oban.Web jobs locally comment out these 2 lines
config :sanbase, Oban.Web, queues: false
config :sanbase, Oban.Admin, queues: false

# Disable the Oban.Scrapers jobs in local env.
# When testing Oban.Scrapers jobs locally comment out these 2 lines
# When testing Oban.Scrapers jobs locally comment out this line
config :sanbase, Oban.Scrapers, queues: false

config :sanbase, Sanbase.Messaging.Insight, enabled: "false"
Expand Down
4 changes: 4 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ config :sanbase, Oban.Web,
name: :oban_web,
testing: :manual

config :sanbase, Oban.Admin,
name: :oban_admin,
testing: :manual

config :sanbase, Sanbase.Cryptocompare.Price.HistoricalScheduler,
enabled?: {:system, "CRYPTOCOMPARE_HISTORICAL_OHLCV_PRICES_SCHEDULER_ENABLED", "true"}

Expand Down
17 changes: 16 additions & 1 deletion lib/sanbase/application/admin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ defmodule Sanbase.Application.Admin do
"""
def children() do
# Define workers and child supervisors to be supervised
children = []
children = [
{Oban, oban_admin_config()}
]

opts = [
name: Sanbase.WebSupervisor,
Expand All @@ -28,4 +30,17 @@ defmodule Sanbase.Application.Admin do

{children, opts}
end

def oban_admin_config() do
config = Application.fetch_env!(:sanbase, Oban.Admin)

# In case the DB config or URL is pointing to production, put the proper
# schema in the config. This will be used both on prod and locally when
# connecting to the stage DB. This is automated so when the stage DB is
# used, the config should not be changed manually to include the schema
case Sanbase.Utils.prod_db?() do
true -> Keyword.put(config, :prefix, "sanbase2")
false -> config
end
end
end
3 changes: 2 additions & 1 deletion lib/sanbase/notifications/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ defmodule Sanbase.Notifications.Handler do

alias Sanbase.{Repo, Notifications.Notification}

@oban_conf_name :oban_web
# The metric registry events and manual notifications come from admin pod, so we use the admin Oban config
@oban_conf_name :oban_admin

@default_channels %{
"metric_created" => ["discord", "email"],
Expand Down

0 comments on commit 266d243

Please sign in to comment.