Add the SyncWorkerManual to run sync manually and notify when done.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
b616c0d5a0
commit
44213069c9
@ -0,0 +1,31 @@
|
||||
defmodule DecentralisedBookIndex.SyncWorkerManual do
|
||||
use Oban.Worker,
|
||||
queue: :default,
|
||||
max_attempts: 2,
|
||||
tags: ["sync", "manual"]
|
||||
|
||||
require Logger
|
||||
|
||||
alias DecentralisedBookIndex.SyncTasks.SyncServerTask
|
||||
|
||||
@topic "task:events"
|
||||
|
||||
@impl Oban.Worker
|
||||
def perform(%Oban.Job{args: args} = job) do
|
||||
Logger.info("The manual job (#{job.id}) run SyncServerTask at #{DateTime.utc_now()} with args: #{inspect(args)}")
|
||||
|
||||
result = SyncServerTask.sync_all()
|
||||
|
||||
Phoenix.PubSub.broadcast!(
|
||||
DecentralisedBookIndex.PubSub,
|
||||
@topic,
|
||||
{:manual_sync_completed, result}
|
||||
)
|
||||
|
||||
Logger.info("The manual job (#{job.id}) is done.")
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
def topic, do: @topic
|
||||
end
|
Loading…
Reference in new issue