Skip to content

Commit

Permalink
Improve crash handling
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idpwn committed Apr 6, 2023
1 parent 1546594 commit a0b3d1f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/kafkaesque/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Kafkaesque.Pipeline do
GenServer.start_link(__MODULE__, opts)
end

@impl GenServer
def init(opts) do
Process.flag(:trap_exit, true)

Expand All @@ -41,6 +42,12 @@ defmodule Kafkaesque.Pipeline do
}}
end

@impl GenServer
def handle_info({:EXIT, _pid, reason}, state) do
{:stop, reason, state}
end

@impl GenServer
def terminate(:shutdown, state) do
# Drain
:ok = Producer.stop_producing(state.producer)
Expand Down

0 comments on commit a0b3d1f

Please sign in to comment.