Remove queue pausing from PropagationGridWorker
This commit is contained in:
parent
15a09f0d7b
commit
d95098daa9
1 changed files with 22 additions and 32 deletions
|
|
@ -18,9 +18,6 @@ defmodule Microwaveprop.Workers.PropagationGridWorker do
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
# Pause these queues while the grid fetch runs so they don't compete for bandwidth.
|
|
||||||
# Keep :hrrr running so on-demand contact detail fetches aren't blocked.
|
|
||||||
@pause_queues [:weather, :iemre, :terrain]
|
|
||||||
@max_forecast_hour 18
|
@max_forecast_hour 18
|
||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
|
|
@ -34,41 +31,34 @@ defmodule Microwaveprop.Workers.PropagationGridWorker do
|
||||||
|
|
||||||
Logger.info("PropagationGrid: run_time=#{run_time}, #{length(points)} points, f00-f#{@max_forecast_hour}")
|
Logger.info("PropagationGrid: run_time=#{run_time}, #{length(points)} points, f00-f#{@max_forecast_hour}")
|
||||||
|
|
||||||
Enum.each(@pause_queues, &Oban.pause_queue(queue: &1))
|
for_result =
|
||||||
|
for fh <- 0..@max_forecast_hour do
|
||||||
|
valid_time = DateTime.add(run_time, fh * 3600, :second)
|
||||||
|
result = process_forecast_hour(points, run_time, fh, valid_time)
|
||||||
|
|
||||||
try do
|
case result do
|
||||||
for_result =
|
:ok -> valid_time
|
||||||
for fh <- 0..@max_forecast_hour do
|
_ -> nil
|
||||||
valid_time = DateTime.add(run_time, fh * 3600, :second)
|
|
||||||
result = process_forecast_hour(points, run_time, fh, valid_time)
|
|
||||||
|
|
||||||
case result do
|
|
||||||
:ok -> valid_time
|
|
||||||
_ -> nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
valid_times = Enum.reject(for_result, &is_nil/1)
|
|
||||||
|
|
||||||
if valid_times != [] do
|
|
||||||
Phoenix.PubSub.broadcast(
|
|
||||||
Microwaveprop.PubSub,
|
|
||||||
"propagation:updated",
|
|
||||||
{:propagation_updated, valid_times}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
total_ms = System.monotonic_time(:millisecond) - t_start
|
valid_times = Enum.reject(for_result, &is_nil/1)
|
||||||
Logger.info("PropagationGrid: total time #{format_duration(total_ms)} (#{length(valid_times)} forecast hours)")
|
|
||||||
|
|
||||||
:ok
|
if valid_times != [] do
|
||||||
after
|
Phoenix.PubSub.broadcast(
|
||||||
Logger.info("PropagationGrid: resuming backfill queues")
|
Microwaveprop.PubSub,
|
||||||
Enum.each(@pause_queues, &Oban.resume_queue(queue: &1))
|
"propagation:updated",
|
||||||
|
{:propagation_updated, valid_times}
|
||||||
Weather.prune_old_grid_profiles()
|
)
|
||||||
Propagation.prune_old_scores()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
total_ms = System.monotonic_time(:millisecond) - t_start
|
||||||
|
Logger.info("PropagationGrid: total time #{format_duration(total_ms)} (#{length(valid_times)} forecast hours)")
|
||||||
|
|
||||||
|
Weather.prune_old_grid_profiles()
|
||||||
|
Propagation.prune_old_scores()
|
||||||
|
|
||||||
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
defp process_forecast_hour(points, run_time, forecast_hour, valid_time) do
|
defp process_forecast_hour(points, run_time, forecast_hour, valid_time) do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue