Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Sep 6, 2024
1 parent 54242d1 commit 3f83898
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/radiator/job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ defmodule Radiator.Job do
defstruct [:work, :id, :max_retries, retries: 0, status: "new"]

def start_job(args) do
if Enum.count(running_imports()) >= 5 do
if Enum.count(running_jobs()) >= 5 do
{:error, :import_quota_reached}
else
DynamicSupervisor.start_child(JobRunner, {JobSupervisor, args})
end
end

def running_imports() do
def running_jobs do
match_all = {:"$1", :"$2", :"$3"}
guards = [{:==, :"$3", "import"}]
map_result = [%{id: :"$1", pid: :"$2", type: :"$3"}]
Expand Down
5 changes: 4 additions & 1 deletion lib/radiator/job_supervisor.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

defmodule Radiator.JobSupervisor do
@moduledoc """
A Supervisor for each job for greater flexibility. Starts as a child of
JobRunner and as a Supervisor for each job
"""
use Supervisor, restart: :temporary

def start_link(args) do
Expand Down

0 comments on commit 3f83898

Please sign in to comment.