Skip to content

Commit

Permalink
VIP - fix type and duplicate PubSub
Browse files Browse the repository at this point in the history
  • Loading branch information
shahryarjb committed May 22, 2024
1 parent c46029e commit ca81f97
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ defmodule MishkaInstaller.Application do
child_spec: Task.Supervisor, name: MishkaInstaller.MnesiaTaskSupervisors},
{PartitionSupervisor,
child_spec: Task.Supervisor, name: MishkaInstaller.JobTaskSupervisors},
{Phoenix.PubSub, name: MishkaInstaller.Queue.PubSub},
{Phoenix.PubSub, name: MishkaInstaller.Hook.PubSub},
{Phoenix.PubSub, name: MishkaInstaller.PubSub, id: "queue"},
MishkaInstaller.ProcessingPipelines.Queue.Queue,
MishkaInstaller.PluginsManagement.Event
]
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins_management/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ defmodule MishkaInstaller.PluginsManagement.Event do

def hold_statuses(deps_list) do
Enum.reduce(deps_list, [], fn item, acc ->
with {:ok, struct} <- read(name: item),
with struct when not is_nil(struct) and not is_tuple(struct) <- read(name: item),
true <- struct.status not in [:registered, :stopped, :held] do
acc
else
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins_management/hook.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule MishkaInstaller.PluginsManagement.Hook do
{:ok, {_ev, _pr}} <- Hook.extension_loaded(config(:app), plg.extension),
deps_list <- Event.hold_statuses(plg.depends),
{:ok, db_plg} <-
Event.create({:ok, Map.merge(plg, depends_status(deps_list, plg.status))}),
Event.create({:ok, Map.merge(plg, Hook.depends_status(deps_list, plg.status))}),
:ok <- Hook.broadcast(:register, db_plg) do
{:ok, :register, db_plg}
end
Expand Down Expand Up @@ -108,7 +108,7 @@ defmodule MishkaInstaller.PluginsManagement.Hook do

@doc false
def broadcast(status, data, channel \\ "hook") do
Phoenix.PubSub.broadcast(MishkaInstaller.Hook.PubSub, "plugin:#{channel}", %{
Phoenix.PubSub.broadcast(MishkaInstaller.PubSub, "plugin:#{channel}", %{
status: status,
data: data
})
Expand Down
2 changes: 1 addition & 1 deletion lib/processing_pipelines/queue/job.ex
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ defmodule MishkaInstaller.ProcessingPipelines.Queue.Job do
end

defp job_broadcast(worker, status, data) do
Phoenix.PubSub.broadcast(MishkaInstaller.Queue.PubSub, "queue:job", %{
Phoenix.PubSub.broadcast(MishkaInstaller.PubSub, "queue:job", %{
worker: worker,
status: status,
data: data
Expand Down
2 changes: 1 addition & 1 deletion lib/processing_pipelines/queue/worker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ defmodule MishkaInstaller.ProcessingPipelines.Queue.Worker do
####################################################################################
@doc false
def queue_broadcast(id, status, answer, worker) do
Phoenix.PubSub.broadcast(MishkaInstaller.Queue.PubSub, "queue:worker", %{
Phoenix.PubSub.broadcast(MishkaInstaller.PubSub, "queue:worker", %{
queue_id: id,
status: status,
worker: worker,
Expand Down
4 changes: 2 additions & 2 deletions test/processing_pipelines/queue/queue_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ defmodule MishkaInstallerTest.ProcessingPipelines.Queue.QueueTest do
alias MishkaInstallerTest.Support.MishkaQueue.{WorkerOne, WorkerThree}

setup %{} do
Phoenix.PubSub.subscribe(MishkaInstaller.Queue.PubSub, "queue:job")
Phoenix.PubSub.subscribe(MishkaInstaller.Queue.PubSub, "queue:worker")
Phoenix.PubSub.subscribe(MishkaInstaller.PubSub, "queue:job")
Phoenix.PubSub.subscribe(MishkaInstaller.PubSub, "queue:worker")
end

###################################################################################
Expand Down

0 comments on commit ca81f97

Please sign in to comment.