Add the SyncWorker and its cron configuration for Oban.
This commit is contained in:
+10
-1
@@ -8,7 +8,16 @@
|
|||||||
import Config
|
import Config
|
||||||
|
|
||||||
config :ash_oban, pro?: false
|
config :ash_oban, pro?: false
|
||||||
config :decentralised_book_index, Oban, plugins: [{Oban.Plugins.Cron, []}]
|
config :decentralised_book_index, Oban,
|
||||||
|
repo: DecentralisedBookIndex.Repo,
|
||||||
|
queues: [default: 14],
|
||||||
|
plugins: [
|
||||||
|
Oban.Plugins.Pruner,
|
||||||
|
{Oban.Plugins.Cron,
|
||||||
|
crontab: [
|
||||||
|
{"@daily", DecentralisedBookIndex.SyncWorker},
|
||||||
|
]}
|
||||||
|
]
|
||||||
|
|
||||||
config :mime,
|
config :mime,
|
||||||
extensions: %{"json" => "application/vnd.api+json"},
|
extensions: %{"json" => "application/vnd.api+json"},
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
defmodule DecentralisedBookIndex.SyncWorker do
|
||||||
|
use Oban.Worker,
|
||||||
|
queue: :default,
|
||||||
|
max_attempts: 2,
|
||||||
|
tags: ["sync", "cron"]
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
|
@impl Oban.Worker
|
||||||
|
def perform(%Oban.Job{args: args} = job) do
|
||||||
|
SyncServerTask.sync_all()
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user