Skip to content

Commit

Permalink
Add Task to event handler call
Browse files Browse the repository at this point in the history
  • Loading branch information
rgarfield11 committed Feb 21, 2025
1 parent 440d3c6 commit d7f7c6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/slax.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ defmodule Slax do
Slax.Repo,
SlaxWeb.Endpoint,
Slax.Scheduler,
{Oban, Application.fetch_env!(:slax, Oban)}
{Oban, Application.fetch_env!(:slax, Oban)},
{Task.Supervisor, name: Slax.TaskSupervisor},
] ++ optional_children()

opts = [strategy: :one_for_one, name: Slax.Supervisor]
Expand Down
4 changes: 3 additions & 1 deletion lib/slax_web/websocket_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ defmodule SlaxWeb.WebsocketListener do
channel = Channels.get_by_channel_id(channel)

if is_nil(channel) or !channel.disabled do
Issue.handle_event(event)
Task.Supervisor.start_child(Slax.TaskSupervisor, fn ->
Issue.handle_event(event)
end)

case Jason.encode(%{envelope_id: envelope_id}) do
{:ok, response} -> :gun.ws_send(pid, stream_ref, {:text, response})
Expand Down

0 comments on commit d7f7c6a

Please sign in to comment.